HTML DOM Strong object


The HTML DOM Strong object is associated with the HTML <strong> element. The strong tag is used for strong emphasis and makes the text bold. We can create and access strong element using the createElement() and getElementById() method respectively.

Syntax

Following is the syntax for −

Creating a strong object −

Var s= document.createElement("STRONG");

Example

Let us look at an example for the strong object −

Live Demo

<!DOCTYPE html>
<html>
<body>
<h1>Strong object example</h1>
<p>Create a strong element by clicking the below button</p>
<button onclick="createStrong">CREATE</button>
<p>This is some text inside the p element</p>
<script>
   function createStrong() {
      var s = document.createElement("STRONG");
      var txt = document.createTextNode("This is some text inside the strong element");
      s.appendChild(txt);
      document.body.appendChild(s);
   }
</script>
</body>
</html>

Output

This will produce the following output −

On clicking the CREATE button −

Updated on: 19-Feb-2021

127 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements