The DOM HR Object is used to represent the HTML <hr> element. The hr element is accessed by getElementById().
Properties:
- Align: It is used to set or return the alignment of a horizontal element.
- color: It is used to set or return the color of the horizontal element.
- noshade: It is used to set or return the noshade property in a horizontal element.
- size: It is used to set or return the height of a horizontal line.
- width: It is used to set or return the width of a horizontal line.
Syntax:
document.getElementById("ID");
Where “ID” represent the element id.
Example-1:
<!DOCTYPE html> <html> <head> <title>HTML hr tag</title> </head> <body> <H1>GeeksForGeeks</H1> <h2>DOM HR Object</h2> <p>There is a horizontal rule below this paragraph.</p> <!-- Assigning id to 'hr' tag. --> <hr id="GFG"> <p>This is a horizontal rule above this paragraph.</p> <button onclick="myGeeks()">Try it</button> <script> function myGeeks() { // Accessing 'hr' tag. var x = document.getElementById("GFG"); x.style.display = "none"; } </script> </body> </html> |
Output:
Before Clicking On Button :

After Clicking on Button:

Example-2: HR Object can be created by using the document.createElement Method.
<!DOCTYPE html> <html> <head> <title>HTML hr tag</title> </head> <body> <h1 style="color:green;">GeeksForGeeks</h1> <h2>DOM HR Object</h2> <button onclick="myGeeks()">Submit</button> <script> function myGeeks() { var g = document.createElement("HR"); document.body.appendChild(g); } </script> </body> </html> |
Output:
Before Clicking On Button:

After Clicking On Button:

Supported Browsers: The browser supported by DOM HR Object are listed below:
- Google Chrome
- Internet Explorer
- Firefox
- Opera
- Safari
Recommended Posts:
- HTML | DOM Object Object
- How to check a JavaScript Object is a DOM Object ?
- HTML | DOM HTML Object
- HTML | DOM Input Week Object
- HTML | DOM Column Object
- HTML | DOM Del Object
- HTML | DOM Embed Object
- HTML | DOM Header Object
- HTML | DOM Footer Object
- HTML | DOM Span Object
- HTML | DOM button Object
- HTML | DOM Blockquote Object
- HTML | DOM BR Object
- HTML | DOM Meta Object
- HTML | DOM Object name Property
- HTML | DOM Abbreviation Object
- HTML DOM Aside Object
- HTML | DOM Bold Object
- HTML | DOM Bdo Object
- HTML | DOM Caption Object
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


