English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
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" |
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.
The table below describes the value of this attribute.
Value | Description |
---|---|
normal | The default value for desktop browsers is approximately1.2and it depends on the element'sfont-family. This is the default value. |
number | A number that will be multiplied by the elementfont-sizeTo set line-height. |
length | The unit is px, pt, cm, em, etc. Negative line height is not allowed. |
percentage | The 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. |
initial | Set 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. |
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.
|
Please refer to the following tutorials:CSS Text.