HTML DOM Style lineHeight Property


The HTML DOM Style lineHeight property is used to set the line height, which is the distance between the lines in a text.

Following is the syntax to set the lineHeight property −

object.style.lineHeight

Following is the syntax to return the lineHeight property −

object.style.lineHeight = "normal|number|length|%|initial|inherit"

Above, the values are described below −

  • normal: Normal line height. Default.
  • number: A number multiplied with the current font size to set the line height
  • length: line height in length units
  • %: line height in % of the current font size
  • initial: Sets this property to its default value.
  • inherit: Inherits this property from its parent element.

Let us now see an example to implement the DOM Style lineHeight property −

Example

 Live Demo

<!DOCTYPE html>
<html>
<body>
<h2>Demo Heading</h2>
<div id="myid">
Here, we have set demo text. Here, we have set demo text. Here, we have set demo text. Here,
we have set demo text. Here, we have set demo text. Here, we have set demo text. Here, we
have set demo text. Here, we have set demo text.
Here, we have set demo text. Here, we have set demo text. Here, we have set demo text. Here,
we have set demo text. Here, we have set demo text. Here, we have set demo text.
</div>
<br>
<button type="button" onclick="display()">Click to increase the line height</button>
<script>
   function display() {
      document.getElementById("myid").style.lineHeight = "3";
   }
</script>
</body>
</html>

Output

Now click the button to set the line height −

Updated on: 30-Jul-2019

45 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements