lineHeight Property - Javascript CSS Style Property

Javascript examples for CSS Style Property:lineHeight

Description

The lineHeight property sets or gets the distance between lines.

Property Values

Value Description
normal Normal line height is used. This is default
number A number to be multiplied with the current font size to set the line height
length line height in length units
% line height in percentage of the current font size
initial Sets this property to its default value.
inherit Inherits this property from its parent element.

Technical Details

Item Value
Default Value: normal?
Return Value: A String, representing the distance between lines in the text
CSS VersionCSS1

Set the line height for a <div> element:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>

<div id="myDiv" style="line-height:450%;">
This is some text. This is some text. This is some text.
This is some text. This is some text. This is some text.
This is some text. This is some text. This is some text.
This is some text. This is some text. This is some text.
</div>/*from   ww w.  j a v a2  s .  c om*/

<button type="button" onclick="myFunction()">Get line height</button>

<script>
function myFunction() {
    document.getElementById("myDiv").style.lineHeight = '20px';
}
</script>

</body>
</html>

Related Tutorials