Open In App

HTML | DOM HR size Property

The DOM HR size property is used to set or return the value of the size attribute of the <hr> element. 

Note : This property is not supported by HTML5



Syntax: 

hrobject.size
hrobject.size="value"

Property Values:  



Return value: It returns a string value that represents the height of the HR element. 

Example 1: This example returns the HR size property.  




<!DOCTYPE html>
<html>
<head>
    <title>HTML DOM HR size property</title>
</head>
<body>
    <h1>GeeksForGeeks</h1>
    <h2>DOM HR size Property</h2>
     
<p>
        There is a horizontal rule
        below this paragraph.
    </p>
 
  
    <!-- Assigning id to 'hr' tag. -->
    <hr id="GFG" align="left" size="10px"
                width="240px" color="red">
     
<p>
        This is a horizontal rule
        above this paragraph.
    </p>
 
    <button onclick="myGeeks()">
        Try it
    </button>
    <h3 id="sudo"></h3>
    <script>
        function myGeeks() {
             
            // return the HR size property
            var x = document.getElementById("GFG").size;
            document.getElementById("sudo").innerHTML = x;
        }
    </script>
</body>
</html>

Example 2: This example sets the HR size property. 




<!DOCTYPE html>
<html>
<head>
    <title>HTML DOM HR size property</title>
</head>
<body>
    <H1>GeeksForGeeks</H1>
    <h2>DOM HR size Property</h2>
     
<p>
        There is a horizontal rule
        below this paragraph.
    </p>
 
     
    <!-- Assigning id to 'hr' tag. -->
    <hr id="GFG" align="left" size="10px"
                width="240px" color="red">
     
<p>
        This is a horizontal rule
        above this paragraph.
    </p>
 
    <button onclick="myGeeks()">Try it</button>
    <h3 id="sudo"></h3>
    <script>
        function myGeeks() {
             
            // set HR size property
            var x =
                document.getElementById("GFG").size = "5";
             
            document.getElementById("sudo").innerHTML
                    = "The value of the size Attribute "
                    + "was changed to " + x;
        }
    </script>
</body>
</html>

Supported Browsers: The browser supported by DOM HR size property are listed below: 


Article Tags :