Last updated on

The line-height property defines the amount of space above and below inline elements. That is, elements that are set to display: inline or display: inline-block. This property is most often used to set the leading for lines of text.

p {
    line-height: 1.5;
}

The line-height property can accept the keyword values normal or none as well as a number, length, or percentage.

According to the spec, a value of “normal” is not just a single concrete value that is applied to all elements, but rather computes to a “reasonable” value depending on the font size set (or inherited) on the element.

A length value can be defined using any valid CSS unit (px, em, rem, etc).

A percentage value is the font size of the element multiplied by the percentage. For example:

<p class="p1"><strong>Paragraph 1:</strong> Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.</p>

<p class="p2"><strong>Paragraph 2:</strong> Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.</p>

<p class="p3"><strong>Paragraph 3:</strong> Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.</p>
body {
  line-height: 1;
  font-size: 20px;
}

p {
  margin: 20px auto;
  max-width: 600px;
}

.p1 {
  line-height: 150%;
}

.p2 {
  line-height: 200%;
}

.p3 {
  line-height: 250%;
}

In the demo above, the three paragraphs have their line heights set to 150%, 200%, and 250%, respectively. The body element has its font size defined at 20px. This means the computed line heights for the paragraphs are 30px, 40px, and 50px, respectively.

Unitless Line Heights

The recommended method for defining line height is using a number value, referred to as a “unitless” line height. A number value can be any number, including a decimal-based number, as is used in the first code example on this page.

Unitless line heights are recommended due to the fact that child elements will inherit the raw number value, rather than the computed value. With this, child elements can compute their line heights based on their computed font size, rather than inheriting an arbitrary value from a parent that is more likely to need overriding.

Related Properties

Browser Support

Chrome Safari Firefox Opera IE Android iOS
Works Works Works Works Works Works Works

IE6/7 will miscalculate the line height on replaced elements (e.g. form controls) that are inline.

Leave a Reply

Your email address will not be published. Required fields are marked *