I didn't think the order of CSS within a rule set mattered, as long as there weren't implicitly duplicate rules (such as border
and border-top
).
In fact, many CSS Style Guides recommend an arbitrary order such as "By group" or "Alphabetically."
However, the order of font
and line-height
within a rule set can make a big difference:
div {border: 1px solid gray; float: left;}
#D1 {font: 20px arial; line-height: 3;}
#D2 {line-height: 3; font: 20px arial;}
<div id="D1">This is a test</div>
<div id="D2">This is a test</div>
A unitless line-height should be a multiplier of the font size.
But why does the font
rule have to precede the line-height
rule for this to happen?