Dofactory.com
Dofactory.com
Earn income with your CSS skills
Sign up and we'll send you the best freelance opportunities straight to your inbox.
We're building the largest freelancing marketplace for people like you.
By adding your name & email you agree to our terms, privacy and cookie policies.

CSS line-height

The line-height property specifies the height of a line of text.

Higher values create text with more space between the lines.

And lower values create lines that are closer to each other.

Example

#

Two paragraphs with different line-height values.

A paragraph with a smaller line-height.
A paragraph with a smaller line-height.


A paragraph with a larger line-height.
A paragraph with a larger line-height.

<p style="line-height: 0.9; border: 1px solid steelblue; padding: 20px;">
  A paragraph with a smaller line-height.<br>
  A paragraph with a smaller line-height.<br>
</p>
<br />
<p style="line-height: 1.9; border: 1px solid steelblue; padding: 20px; ">
  A paragraph with a larger line-height.<br>
  A paragraph with a larger line-height.<br>
</p>

Using line-height

The line-height property accepts any length value, such as, px, pt, em, etc.

Both positive and negative values can be used.

This property does not affect inline elements, such as, images, buttons, etc.

Syntax

line-height: normal | number | length | 
             initial | inherit;

Values

#

Value Description
normal Default. Normal line height.
number A number which is multiplied with the current font-size to set the line-height.
length Fixed line height using any CSS length values.
% Line height as a percentage of the current font size.
initial Sets the value to its default value.
inherit Inherits the value from its parent element.

More Examples

Click the buttons to see the different line-height values.

This is a paragraph with line-height: normal.
This is a paragraph with line-height: normal.
This is a paragraph with line-height: normal.

<style>
  .line-height-example {
    line-height: normal;
  }
</style>

<p class="line-height-example">
  This is a paragraph with line-height: normal.<br>
  This is a paragraph with line-height: normal.<br>
  This is a paragraph with line-height: normal.
</p>

Did you know?

Did you know?

The default line-height value

Browsers determine the default line height.

It is generally 110% or 120% of the text size of the element.


Browser support

This table shows when line-height support started for each browser.

Chrome
1.0 Dec 2008
Firefox
1.0 Nov 2004
IE/Edge
4.0 Sep 1997
Opera
7.0 Jan 2003
Safari
1.0 Jun 2003

You may also like


Last updated on Sep 30, 2023

Earn income with your CSS skills
Sign up and we'll send you the best freelance opportunities straight to your inbox.
We're building the largest freelancing marketplace for people like you.
By adding your name & email you agree to our terms, privacy and cookie policies.

Guides