InfoHeap
Tech
Navigation
  • Home
  • Tutorials
    • CSS tutorials & examples
    • CSS properties
    • Javascript cookbook
    • Linux/Unix Command Line
    • Mac
    • PHP
      • PHP functions online
      • PHP regex
    • WordPress
  • Online Tools
    • Text utilities
    • Online Lint Tools
search

CSS properties

  • CSS3 flexbox
  • all
  • animation
  • background-color
  • background-image
  • border
  • border-color
  • border-radius
  • border-style
  • border-width
  • bottom
  • box-shadow
  • box-sizing
  • calc function
  • clip
  • color
  • color value currentColor
  • color values
  • cursor
  • float
  • font
  • font-family
  • font-size
  • font-style
  • font-variant
  • font-weight
  • generated content
  • left
  • letter-spacing
  • line-height
  • list-style
  • list-style-image
  • list-style-position
  • list-style-type
  • margin
  • max-height
  • max-width
  • min-height
  • min-width
  • opacity
  • outline
  • outline-color
  • outline-style
  • outline-width
  • overflow
  • padding
  • pointer-events
  • position
  • resize
  • right
  • text-align
  • text-decoration
  • text-indent
  • text-overflow
  • text-shadow
  • text-transform
  • top
  • transform
  • transition
  • transition-delay
  • transition-duration
  • transition-property
  • transition-timing-function
  • visibility
  • white-space
  • word-break
  • word-spacing
  • word-wrap/overflow-wrap
  • z-index
 
  • Home
  • > Tutorials
  • > CSS
  • > CSS properties

CSS line-height – set minimum height of line box

on Feb 18, 2016

On block level elements, the line-height property specifies the minimum height of line boxes within the element.

CSS property line-height

CSS version: CSS 2.1
Value: normal | number | length | percentage
Initial: normal
Applies to: all elements
Inherited: yes

line-height values

Value typeInterpretationInheritance
normal (default)roughly 1.2 depending upon font-family-
number (preferred)number * font-sizeValue is inherited before computation
length (avoid)1.2em, etc.Value is inherited after computation. Can lead to unexpected results
length (avoid)percentage * font-sizeValue is inherited after computation. Can lead to unexpected results

Comment on inheritance

In case font value is in number, the value is inherited as it is and computation applies on child element font-size. For value in length or percentage, it is computed and then inherited. In case child font being very large, this can lead to a situation line-height being less than font.

line-height number value example with inheritance

This is the preferred option and inheritance does not cause unexpected results.

<style type="text/css">
.outer {
  width: 100px;
  font-size: 14px;
  line-height: 1.2;
}
h1 {font-size: 30px;}
</style>
<div class="outer">
<h1>This is in h1</h1>
Hello world - just normal text
</div>
refresh done
try it online

line-height length (em) value example with inheritance

When using line-height length (em) value, inheritance can cause expected results.

<style type="text/css">
.outer {
  width: 100px;
  font-size: 14px;
  line-height: 1.2em;
}
h1 {font-size: 30px;}
</style>
<div class="outer">
<h1>This is in h1</h1>
Hello world - just normal text
</div>
refresh done
try it online

line-height percentage value example with inheritance

When using line-height percentage value, inheritance can cause expected results.

<style type="text/css">
.outer {
  width: 100px;
  font-size: 14px;
  line-height: 120%;
}
h1 {font-size: 30px;}
</style>
<div class="outer">
<h1>This is in h1</h1>
Hello world - just normal text
</div>
refresh done
try it online

Specification

  • W3C CSS 2.1 line-height specification

Suggested posts:

  1. Composer – quick start guide on Linux and Mac
  2. CSS min-height – set minimum height of an element
  3. CSS pointer-events – disable click on an element
  4. CSS color value currentColor
  5. How to install and run Chrome PageSpeed insights for measuring site performance
  6. AngularJS hello world example
  7. CSS font-size
  8. CSS font-style
Share this article: share on facebook share on linkedin tweet this submit to reddit
Posted in Tutorials | Tagged CSS, CSS properties, Tutorials
  • Browse content
  • Article Topics
  • Article archives
  • Contact Us
Popular Topics: Android Development | AngularJS | Apache | AWS and EC2 | Bash shell scripting | Chrome developer tools | Company results | CSS | CSS cookbook | CSS properties | CSS Pseudo Classes | CSS selectors | CSS3 | CSS3 flexbox | Devops | Git | HTML | HTML5 | Java | Javascript | Javascript cookbook | Javascript DOM | jQuery | Kubernetes | Linux | Linux/Unix Command Line | Mac | Mac Command Line | Mysql | Networking | Node.js | Online Tools | PHP | PHP cookbook | PHP Regex | Python | Python array | Python cookbook | SEO | Site Performance | SSH | Ubuntu Linux | Web Development | Webmaster | Wordpress | Wordpress customization | Wordpress How To | Wordpress Mysql Queries | InfoHeap Money

Copyright © 2025 InfoHeap.

Powered by WordPress