css – inline elements ignoring line-height

What webkit inspector shows (and what you measured in PhotoShop) is the content area‘s dimensions.

See http://www.w3.org/TR/CSS2/visudet.html#inline-non-replaced

The height of the content area [of inline elements] should be based on the font, but this specification does not specify how. A UA may, e.g., use the em-box or the maximum ascender and descender of the font…

Different browsers simply use a different approach here. See http://jsfiddle.net/ejqTD/1/ for an illustration of that. Note how webkit renders a higher content area, but line-height is still correct.

The content area exceeds the line box in this case, which is permitted: http://www.w3.org/TR/CSS2/visudet.html#leading

if the height specified by ‘line-height’ is less than the content height of contained boxes, backgrounds and colors of padding and borders may “bleed” into adjoining line boxes.

It’s easy to see if you consider line-heights < 1: http://jsfiddle.net/KKMmK/

Leave a Comment