CSS

🎯 What is line-height?

The line-height property is used to define the vertical space between lines of text inside a block element.

In other words, it controls how close or how far apart lines of text appear from each other.

This property is very important for:

  • Improving readability
  • Creating visual balance in paragraphs
  • Making text look more spacious or compact in design

🔹 Basic Usage

CSS

p { 
    line-height: 1.5; 
}
                

➡️ In this example, each line has a height equal to 1.5 times the font size.

This adds extra spacing between lines, making the text easier to read.

🔹 Values

1. normal

This is the default value.

The browser automatically calculates an appropriate line height based on the font.

🧩 Example

CSS

p { 
    line-height: normal; 
}
                

➡️ Usually results in a line height around 1.2 × font size, depending on the font family.

2. number

Defines line height as a multiplier of the font size.

This is a relative value, not fixed in pixels.

🧩 Example

CSS

p { 
    font-size: 16px;
    line-height: 2; 
}
                

➡️ Line height = 16px × 2 = 32px

This creates a more spacious and readable layout.

3. length

Sets a fixed line height using units such as:

  • px
  • em
  • rem
  • pt

🧩 Example

CSS

p { 
    line-height: 24px; 
}
                

➡️ Each line will always be 24px tall, regardless of font size.

4. % (Percentage)

Defines line height as a percentage of the font size.

🧩 Example

CSS

p { 
    line-height: 150%; 
}
                

➡️ If font size is 20px:

  • Line height = 20 × 1.5 = 30px

5. initial

Resets the line height to its default value ( normal ).

🧩 Example

CSS

p { 
    line-height: initial; 
}
                

5. inherit

The element inherits the line-height value from its parent element.

🧩 Example

CSS

div { 
    line-height: 2;
}

p { 
    line-height: inherit;
}
                

➡️ The <p> element inherits the value 2 from the <div>.

💡 Summary Table

Value Description
normal Browser sets default spacing
number Multiplies font size (e.g., 1.5, 2)
length Fixed value (px, em, rem, etc.)
% Percentage of font size
initial Resets to default ( normal )
inherit Takes value from parent
  • 🧠 Summary

  • The line-height property controls the vertical spacing between lines of text.
  • Common usage examples:
  • 1.2 → tight and compact text
  • 1.5 → balanced and readable text
  • 2 → wide and airy layout
  • Proper use of line-height greatly improves:
  • Readability
  • Visual hierarchy
  • Overall UI design quality