- 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 Superscript Object
The HTML DOM superscript Object represent the <sup> element of an HTML document.
Let us see how to create superscript object −
Syntax
Following is the syntax −
document.createElement(“SUP”);
Example
Let us see an example of superscript object −
<!DOCTYPE html> <html> <head> <style> body { text-align: center; background-color: #fff; color: #0197F6; } h1 { color: #23CE6B; } .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; } </style> </head> <body> <h1>DOM superscript Object Demo</h1> <button onclick="createSup()" class="btn">Create a superscript object</button> <script> function createSup() { var supElement = document.createElement("SUP"); supElement.innerHTML = "This is a superscript element" document.body.appendChild(supElement); } </script> </body> </html>
Output
This will produce the following output −
Click on “Create a superscript object” button to create a superscript object. The text visible after clicking the button is a superscript text, which appears half a character above the normal line −
Advertisements