HTML & CSS Wiki

READ MORE

HTML & CSS Wiki

The line-height property is used in CSS and certain HTML elements. On inline elements, this property specifies the height that is used in the calculation of the line box height. On block-level elements, it specifies the minimal height of line boxes within the element.


Values[]

  • normal - Depends on the user agent. Desktop browsers use a default value of roughly 1.2, depending on the element's font-family.
  • <number> - The used value is this unit-less <number> multiplied by the element's font size. The computed value is the same as the specified <number>. In most cases this is is the preferred way to set line-height with no unexpected results in case of inheritance.
  • <length> - The specified <length> is used in the calculation of the line box height. Examples of length values are pt, pt, px, em, etc.
  • <percentage> - Relative to the font size of the element itself. The computed value is this percentage multiplied by the element's computed font size.

Note: <percentage> and em values may have unexpected results.


HTML example:

<span style="line-height:10px;">QWERTY</span>


CSS example:

h1 {
    line-height:10px;
}