HTML DOM small object

HTMLWeb DevelopmentFront End Technology

The HTML DOM small object is associated with HTML <small> element. We can create and access small element using the createElement() and getElementById() method respectively.

Syntax

Following is the syntax for −

Creating a small object −

var s= document.createElement("SMALL");

Example

Let us look at an example for the small object −

<!DOCTYPE html>
<html>
<body>
<h1>Small object example</h1>
<p>Create a small element containing some text by clicking the below button</p>
<button onclick="CreateSmall()">CREATE</button>
<p>This is normal text</p>
<script>
   function CreateSmall() {
      var s = document.createElement("SMALL");
      var txt = document.createTextNode("This is small text");
      s.appendChild(txt);
      document.body.appendChild(s);
   }
</script>
</body>
</html>

Output

This will produce the following output −

On clicking the CREATE button −

raja
Published on 19-Aug-2019 12:45:56
Advertisements