Get the line height of a <div> element: - Javascript CSS Style Property

Javascript examples for CSS Style Property:lineHeight

Description

Get the line height of 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>/*w w  w .  j  ava2 s. com*/

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

<script>
function myFunction() {
    console.log(document.getElementById("myDiv").style.lineHeight);
}
</script>

</body>
</html>

Related Tutorials