CSS line-height does not need a unit

In case you didn't already know, the CSS property line-height does not need a unit. Eric Meyer explains the details in Unitless line-heights.

I knew about this, but I wasn't quite aware of the difference between specifying a value and not. I did notice that I sometimes would get different results, but thought it had to do with browser quirkiness. Looks like I was wrong there.

Oh, a small tip: to avoid triggering a validation error when you specify line-height:1, use line-height:1.0 instead. Both are correct, but the CSS validator is buggy and doesn't know that.

Posted on March 24, 2006 in Quicklinks, CSS