HTML | DOM Style lineHeight Property

The Style lineHeight property is used for setting or returning the distance between lines in a text. It is a string which represents the distance between lines in the text.

    Syntax:

  • To return the line-height.
    object.style.lineHeight
  • To set the line-height.
    object.style.lineHeight = "normal|number|length|%|initial|inherit"

Property Values :

  • normal : It is used to define the normal height.
  • number : It is used to define a number that will be multiplied with the current font size to set the line height.
  • length : It is used to define the line height in length units.
  • % : It is used to define the line height in % of the current font size.
  • initial : It is used to set this property to its default value.
  • inherit : It is used to inherit this property from its parent element.

Below program illustrates the Style lineHeight property :
Example: Setting the line height for a <div> element.

filter_none

edit
close

play_arrow

link
brightness_4
code

<!DOCTYPE html>
<html>
  
<head>
    <title> Style lineHeight property in HTML</title>
    <style>
        #samplediv {
            border: 1px solid green;
        }
          
        h1 {
            color: green;
        }
          
        h2 {
            font-family: Impact;
        }
          
        body {
            text-align: center;
        }
    </style>
</head>
  
<body>
  
    <h1>GeeksforGeeks</h1>
    <h2> Style lineHeight property </h2>
    <br>
  
    <div id="MyDiv">
        GeeksforGeeks offers the following courses :
        <ul>
            <li> Fork Python </li>
            <li> Fork CPP </li>
            <li> Fork Java </li>
            <li> Sudo Placement </li>
        </ul>
    </div>
    <br>
  
    <button type="button" ondblclick="lineheight()">
      Adjust Line Height
    </button>
  
    <script>
        function lineheight() {
            
            //  Set lineHeight.
            document.getElementById(
              "MyDiv").style.lineHeight = 
              "2";
        }
    </script>
  
</body>
  
</html>

chevron_right


Output:

Before clicking the button:

After clicking the button:

Supported Browsers:

  • Opera
  • Internet Explorer
  • Google Chrome
  • Firefox
  • Apple Safari


My Personal Notes arrow_drop_up

I am a technology enthusiast who has a keen interest in programming I am pursuing Engineering in Computer Science from GEU, Dehradun I like to unwind by watching movies and English sitcomsI have a keen interest in music

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.



Improved By : shubham_singh



Article Tags :
Practice Tags :


Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.