Little Web Hut

CSS 2.1 Reference: line-height Property

CSS line-height Property
Syntax
selector {line-height: value;}
  • value is specified by using a number, length, percentage, or one of the following keywords: normal or inherit.
Usage

The line-height property is used to specify the line height.

This property is specified by using a number, length, percentage, or keyword, according to the syntax shown above. Values cannot be negative.

  • If a number value is used, then the line height will equal the number multiplied by the element's font size.
  • If a percentage value is used, then the line height will be a percentage of the element's font size.

CSS Example: The line-height properties are set using a number, length, percentage, and a keyword.
  #tst1 {line-height: 1.8; background-color: yellow;}
  #tst2 {line-height: 15px; background-color: orange;}
  #tst3 {line-height: 150%; background-color: yellow;}
  #tst4 {line-height: normal; background-color: orange;}
Test It HTML StyleTest It XHTML StyleTest It HTML5 Style

Keywords
  • normal - Normal line height for the font that is being used.
  • inherit - The inherit keyword is used to specify that the value for this property should be taken from the parent element. If inherit is used with the root element, then the initial value for this property will be used.
Applies To All elements
Inherited Yes
Initial Value normal


line-height Property Examples
Test It HTML StyleTest It HTML StyleTest It HTML5 StyleThe line-height properties are set using a number, length, percentage, and a keyword.