- 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 Pre Object
The HTML DOM Pre Object represent the <pre> element of an HTML document.
Create pre object
Syntax
Following is the syntax:
document.createElement(“PRE”);
Example
Let us see an example of pre object −
<!DOCTYPE html> <html> <head> <style> body{ text-align:center; background-color:#fff; color:#0197F6; } h1{ color:#23CE6B; } .drop-down{ width:35%; border:2px solid #fff; font-weight:bold; padding:8px; } .btn{ background-color:#fff; border:1.5px dashed #0197F6; height:2rem; border-radius:2px; width:60%; margin:2rem auto; display:block; color:#0197F6; outline:none; cursor:pointer; } pre{ font-size:1.2rem; color:#db133a; } </style> </head> <body> <h1>DOM pre Object Demo</h1> <button onclick="createPre()" class="btn">Create a pre object</button> <script> function createPre() { var preElement = document.createElement("PRE"); preElement.innerHTML="Hi! I'm a pre HTML element"; document.body.appendChild(preElement); } </script> </body> </html>
Output
This will produce the following output −
Click on “Create a pre object” button to create a pre object.
Advertisements