Code has been added to clipboard!

The CSS Line-Height Property

Reading time 1 min
Published Sep 8, 2017
Updated Oct 10, 2019

What does CSS line height mean?

Using the CSS line-height property, you can specify a custom height for a line box:

Example
p.small {
    line-height: 20px;
}

p.big {
    line-height: 40px;
}

Increasing the CSS line height means adding extra space over and under the actual text characters. Manipulating this property allows you to change CSS line spacing, making the text easier to read:

Example
p.small {
    line-height: 0.6;
}

p.big {
    line-height: 3;
}

The syntax for CSS line-height

The line-height CSS property requires to define one value:

line-height: value;

You can find all the ways to specify the value for the CSS line height in the table below.

Udacity
Pros
  • Simplistic design (no unnecessary information)
  • High-quality courses (even the free ones)
  • Variety of features
Main Features
  • Nanodegree programs
  • Suitable for enterprises
  • Paid certificates of completion
Coursera
Pros
  • Professional service
  • Flexible timetables
  • A variety of features to choose from
Main Features
  • Professional certificates of completion
  • University-level courses
  • Multiple Online degree programs
Datacamp
Pros
  • Great user experience
  • Offers quality content
  • Very transparent with their pricing
Main Features
  • Free certificates of completion
  • Focused on data science skills
  • Flexible learning timetable

CSS line height values

Value Description
normal The default value. Represents the font size multiplied by 1.2
Unitless numbers A number to multiply the font size value by
Percentages A percentage to multiply the font size value by
Length units A fixed line height in pt, px, cm, etc.

See one more example to see how percentages can be used for CSS line spacing:

Example
p.small {
    line-height: 80%;
}

p.big {
    line-height: 150%;
}

Browser support

Browser image
Chrome
1+
Browser image
Edge
12+
Browser image
Firefox
1+
Browser image
IE
4+
Browser image
Opera
7+
Browser image
Safari
1+

Mobile browser support

Browser image
Chrome
18+
Browser image
Firefox
4+
Browser image
Opera
10.1+
Browser image
Safari
1+

Latest Udacity Coupon Found:

Verified STAFF PICK

75% OFF COURSES

Udacity Black Friday Offer

The best time to save on Udacity courses is now - follow this coupon to access a 75% Udacity Black Friday discount & enjoy learning at a very low cost!

Expiration date: 18/01/2021
3176 People Used
Only 97 Left
Rating
5.0