XML technologies / CSS / Advanced websites with CSS / CSS property reference / line-height

(Excerpt from “CSS − Advanced websites with Cascading Stylesheets” by Rachel Andrew & Dan Shafer)

The property line-height describes an element’s line height. If a line contains more than one element, the element with the largest setting for line-height determines the height of the entire line.

Inherited: Yes (with differences between the formats listed below)

See also: font and font-size

Values

line-height supports the following formats:

  • normal: This constant is the default value and, according to the CSS specification, corresponds to a numeric value between 1.0 and 1.2.

  • numerischer Wert: A numeric value (for example 1.5), multiplied by the font size, gives the line height. A setting of 1.0 packs lines as tightly as possible without characters overlapping. A setting of 1.2 produces normal line spacing. The value is inherited as a proportional factor and as an absolute value already computed for the parent element. For a child element with larger text, an inherited value produces correspondingly greater line spacing than for the parent element with smaller text.

  • CSS-Maßangabe: An absolute CSS length (for example 50px) or a relative CSS length. A relative value in em (em height) produces the same result as a numeric value, but passes the value already computed for the parent element to child elements rather than a proportional factor.

  • Prozentwert: A percentage multiplied by the font size gives the line height. As with lengths, the line height is proportional to the font size, but child elements inherit the value already computed for the parent element rather than a proportional factor.

Default value: normal

Compatibility

CSS version: 1

Works in all CSS-capable browsers, including Internet Explorer version 4 and later, Netscape version 4 and later, and Mozilla.

Example

The following style rule gives elements of class luftig a line height equal to one and a half times the font size:

.luftig {
 line-height: 1.5;
}

Because a numeric value is declared, child elements’ line height is calculated as a proportional factor of 1.5 times their own font size. If a value of 150% or 1.5em were used instead, child elements would receive the parent element’s absolute line height.

  

 

 

 

back to top