English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

CSS reference manual

CSS @rules

CSS attribute大全

CSS line-Usage and examples of the height property

line-height CSS property settingBlock-levelThe height between text lines within an element (such as a paragraph).

The following table provides usage instructions and version history of this property, as well as the syntax for using this property in JavaScript scripts.

Default value:normal
Applicable to:All elements
Inheritance:is
Animated:is.Please refer to Animation Attribute.
Version:CSS 1,2,3
JavaScript Syntax:object.style.lineHeight="2"

line-The syntax of height

The syntax of this attribute is as follows:

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

The following examples demonstrate how to use line-height Attribute.

  p {
   line-height: 1.5;
  }
  div {
   line-height: 300%;
  }
Test to see‹/›

Warning:Percentage (%) and em values may produce unexpected results. In most cases-height, in the case of inheritance, using a number is the preferred setting method and will not result in unexpected outcomes. Learn more aboutThe CSS unit'sMore Information.

Attribute Value

The table below describes the value of this attribute.

ValueDescription
normalThe default value for desktop browsers is approximately1.2and it depends on the element'sfont-family. This is the default value.
numberA number that will be multiplied by the elementfont-sizeTo set line-height.
lengthThe unit is px, pt, cm, em, etc. Negative line height is not allowed.
percentageThe method of using percentage as a multiplier is the same as that of numeric values-The calculated value of the attribute is equal to the specified percentage value of the elementfont-size.
initialSet this attribute to its default value.
inherit

In the case of inheritance, if the line-If the height attribute uses a numeric value, the child element will inherit the specified value rather than the calculated value of the attribute. Negative values are not allowed.

If a percentage value is used, the child element will inherit the calculated value of the attribute rather than the specified percentage value. Similarly, negative values are not allowed.

Browser Compatibility

line-The compatibility of height Attribute across browsers, the numbers in the table below represent the minimum version number of browsers that support this attribute; all mainstream browsers support this attribute.

  • Firefox 1+

  • Google Chrome1+

  • Internet Explorer 3+

  • Apple Safari 1+

  • Opera 4+

For further reading

Please refer to the following tutorials:CSS Text.

Related Attributes:font,font-size.