CSS line-height
The CSS line-height
property is similar to leading in desktop publishing — it determines the "line height". This results in lines of text appearing closer together or further apart.
On a block container element whose content is composed of inline-level elements, line-height
specifies the minimal height of line boxes within the element.
On a non-replaced inline element, line-height
specifies the height that is used in the calculation of the line box height.
Also see the letter-spacing
and word-spacing
properties.
Syntax
Possible Values
The line-height
property accepts the following values.
normal
- Specifies that the user agent should use a "reasonable" value based on the font of the element. This is typically between
1.0
and1.2
. - length
- Specifies the line height using a length value (for example
1.3em
). The specified length is used in the calculation of the line box height. Negative values are illegal. - number
- Specifies the line height using a number value (for example
1.3
). The used value of the property is this number multiplied by the element's font size. Negative values are illegal. - percentage
- Specifies the line height using a percentage value (for example
130%
). The computed value of the property is this percentage multiplied by the element's computed font size. Negative values are illegal.
In addition, all CSS properties also accept the following CSS-wide keyword values as the sole component of their property value:
initial
- Represents the value specified as the property's initial value.
inherit
- Represents the computed value of the property on the element's parent.
unset
- This value acts as either
inherit
orinitial
, depending on whether the property is inherited or not. In other words, it sets all properties to their parent value if they are inheritable or to their initial value if not inheritable.
General Information
- Initial Value
normal
- Applies To
- All elements
- Inherited?
- Yes
- Media
- Visual
- Animatable
- Yes (see example)
Example Code
Official Specifications
- CSS Transitions (W3C Working Draft — specifies the property as animatable)
- CSS Level 2.1 (W3C Recommendation 07 June 2011)
- CSS Level 1 (W3C Recommendation 17 Dec 1996)