HTML DOM Superscript Object

HTMLWeb DevelopmentFront End Technology

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 −

 Live Demo

<!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 −

raja
Published on 24-Jul-2019 14:08:36
Advertisements