tags:

views:

50

answers:

3

which elements are affected by the line-height property?

+1  A: 

It applies to all HTML elements, but has different behaviour depending on the element.

From the CSS spec:

All elements have a 'line-height' property that, in principle, gives the total height of a line of text.

GenericTypeTea
Ok and does all browser have different line height? should i keep `line-height:0` in css reset?
metal-gear-solid
No it's not in Eric meyer reset http://meyerweb.com/eric/thoughts/2007/05/01/reset-reloaded/ he is using `body {line-height: 1;}`
metal-gear-solid
Don't set line-height to 0. Either leave it at 1, 100% or line-height:normal;
easwee
A: 

Applies to all elements, with different behaviour of course:

http://www.w3.org/TR/CSS2/visudet.html#line-height

On a block-level, table-cell, table-caption or inline-block element whose content is composed of inline-level elements, 'line-height' specifies the minimal height of line boxes within the element. The minimum height consists of a minimum height above the block's baseline and a minimum depth below it, exactly as if each line box starts with a zero-width inline box with the block's font and line height properties (what TEX calls a "strut").

On an inline-level element, 'line-height' specifies the height that is used in the calculation of the line box height (except for inline replaced elements, where the height of the box is given by the 'height' property).

mamoo
A: 

It affects all of them according to the W3 line-height spec. It's behavior is different depending on the type of element it is applied to:

block-level, table-cell, table-caption or inline-block

[on one of the above] whose content is composed of inline-level elements, 'line-height' specifies the minimal height of line boxes within the element.

inline-level

...specifies the height that is used in the calculation of the line box height (except for inline replaced elements, where the height of the box is given by the 'height' property).

Line box height is then defined as:

the distance between the uppermost box top and the lowermost box bottom.

Pat