On 8 Feb, 12:41, "Gary" <garyuse...@myway.comwrote:
line-height: 0.8em !important;
line-height: 1em;
Can someone tell me why there are two entries for the same property
(line-height) please?
They're different rules. Same property, same block (which obviously
implies the same selector). However they have two differences: firstly
one has the "important" keyword added to it, secondly one comes after
the other.
In general, CSS has complicated rules for the cascade and the
"specificity" of the various selectors.
You need to read (and carefully!) the CSS spec for this
http://www.w3.org/TR/CSS21/cascade.html
This case is a bit simpler though, because specificity and origin is
identical for these two rule as they're the same selector in the same
stylesheet. That just leaves the importance and the order to worry
about.
Usually the last rule specified (by order) wins and duplicate rules
simply over-write their predecessors. However this is the very last
CSS ordering step and is of low priority. The important declaration is
of much higher priority (even beating selector specificity) and is of
comparable priority to its origin from either the user or author
stylesheets (the relative prioritisation of these has varied over the
history of CSS). In this case, the first rule simply trumps the later
rule in all cases.
So the 2nd rule is demonstrably superfluous. Hopefully the purpose of
the "tutorial" was to encourage you to spot this, otherwise it's not a
good tutorial to be leaving such dross lying around in it. I _hope_
that the author didn't misunderstand things and thought that the 2nd
rule could _ever_ win, just because it came later?
Line-height should have an initial default of about 1.2. Setting it to
less than 1 is certainly perverse. Although some logos do it
justifiably, I can't imagine it being a good idea in a list of links.
In practice, just leave the damned thing alone, you'll only break
stuff!
It's also a good idea to set line-height as a number (e.g. 1.2) rather
than in a length unit such as ems. This avoids some problems that
might arise if the now-fixed line-height gets inherited by an element
with a different.font size.