Set the line height for a <div> element:
document.getElementById("myDiv").style.lineHeight = "3";
Try it Yourself »
The lineHeight property sets or returns the distance between lines in a text.
Property | |||||
---|---|---|---|---|---|
lineHeight | Yes | Yes | Yes | Yes | Yes |
Return the lineHeight property:
object.style.lineHeight
Set the lineHeight property:
object.style.lineHeight = "normal|
number|
length|
%|initial|inherit"
Value | Description |
---|---|
normal | Normal line height is used. This is default |
number | A number that will be multiplied with the current font size to set the line height |
length | Defines the line height in length units |
% | Defines the line height in % of the current font size |
initial | Sets this property to its default value. Read about initial |
inherit | Inherits this property from its parent element. Read about inherit |
Default Value: | normal |
---|---|
Return Value: | A String, representing the distance between lines in the text |
CSS Version | CSS1 |
Return the line height of a <div> element:
alert(document.getElementById("myDiv").style.lineHeight);
Try it Yourself »
CSS tutorial: CSS Text
CSS reference: line-height property
截取页面反馈部分,让我们更快修复内容!也可以直接跳过填写反馈内容!