csso icon indicating copy to clipboard operation
csso copied to clipboard

Structure optimization of multiple (3 and more) mutual rules

Open p4tient opened this issue 14 years ago • 1 comments

Consider the following code:

a { width: 1%; margin: 0 auto; padding: 1em; }
b { width: 2%; margin: 0 auto; padding: 1em; }
c { width: 3%; margin: 0 auto; padding: 1em; }

With the current implementation the resulting CSS is far from optimal:

a { width: 1%; margin: 0 auto; padding: 1em }
b { width: 2% }
b, c { margin: 0 auto; padding: 1em }
c { width: 3% }

It would be nice to become something like this instead:

a { width: 1% }
b { width: 2% }
c { width: 3% }
a, b, c { margin: 0 auto; padding: 1em }

p4tient avatar Mar 26 '12 12:03 p4tient

Current result is

a,b,c {
    width: 1%;
    margin: 0 auto;
    padding: 1em
}
b,c {
    width: 2%
}
c {
    width: 3%
}

It's much better and correct, but redundant c in 2nd ruleset.

lahmatiy avatar Feb 15 '16 01:02 lahmatiy