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.0and1.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
inheritorinitial, 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 Inline Layout Module Level 3 (W3C Working Draft)
- 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)
Browser Support
Browser support for CSS properties can vary, particularly for newer or experimental features. Check current browser compatibility before using a property in production, especially when supporting older browsers.
Initial Value
CSS properties have an initial value that applies when the property has not been explicitly set. The initial value is different from the value inherited from a parent element and may vary between properties.
Inheritance
Some CSS properties inherit their computed value from their parent element by default, while others do not. The inherit, initial, unset, and revert keywords can also be used to control how a property gets its value.
Vendor Prefixes
Most modern CSS properties use the standard, unprefixed syntax. Vendor-prefixed properties such as -webkit- are mainly relevant to older browser versions or specific features and should only be used when required by your browser support targets.