HTML DOM Bold object


The HTML DOM bold object is associated with the html <b> (bold) tag. The <b> tag is used to make the text inside the <b> tag bold .Using the bold object we can access the HTML <b> tag.

Syntax

Following is the syntax for −

Creating a bold object −

var x = document.createElement("B");

Example

Let us see an example for the HTML DOM Bold object −

<!DOCTYPE html>
<html>
<body>
<p>Click the below button to create a <b> element with some text</p>
<button onclick="createBold()">CREATE</button>
<br><br>
<script>
   function createBold() {
      var x = document.createElement("B");
      var t = document.createTextNode("SAMPLE BOLD TEXT");
      x.appendChild(t);
      document.body.appendChild(x);
   }
</script>
</body>
</html>

Output

This will produce the following output −

On clicking CREATE −

Updated on: 06-Aug-2019

339 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements