- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
HTML DOM HR Object
The HTML DOM HR Object represent the <hr> element of an HTML document.
Create hr object−
Syntax
Following is the syntax −
document.createElement(“HR”);
Let us see an example of hr object−
Example
<!DOCTYPE html> <html> <style> body { text-align: center; background-color: #fff; color: #0197F6; } h1 { color: #23CE6B; } .btn { background-color: #fff; border: 2px solid #0197F6; height: 2rem; width: 40%; margin: 2rem auto; display: block; color: #0197F6; outline: none; cursor: pointer; border-radius: 20px; } hr { border-color: #db133a; } </style> <body> <h1>DOM hr Object Demo</h1> <button onclick="createHr()" class="btn">Create a hr object</button> <script> function createHr() { var insElement = document.createElement("HR"); document.body.appendChild(insElement); } </script> </body> </html>
Output
Click on “Create a hr object” button to create a hr object.
Advertisements