HTML | DOM Bold Object
The DOM Bold Object is used to represent the HTML <b> element. The bold element is accessed by getElementById().
Syntax:
document.getElementById("ID");
Where “id” is the ID assigned to the “b” tag.
Example-1:
<!DOCTYPE html> <html> <head> <title> HTML DOM Bold Object </title> <script> function myGeeks() { var b = document.getElementById("GFG"); b.style.backgroundColor = "red"; } </script> </head> <body> <b></b> <h1 id="GFG">GeeksForGeeks</h1></b> <h2 style="font-size:35px;">DOM Bold Object</h2> <BR> <button onclick="myGeeks()"> Submit </button> <p id="geeks"></p> </body> </html> |
Output:
Before Clicking On the Button:

After Clicking on Button:

Example-2: Bold Object can be created by using the document.createElement Method.
<!DOCTYPE html> <html> <head> <title> HTML DOM Bold Object </title> <!-- script for Bold Object --> <script> function myGeeks() { var G = document.createElement("B"); var F = document.createTextNode("GeeksForGeeks"); G.appendChild(F); document.body.appendChild(G); } </script> </head> <body> <H1>GeeksForGeeks</H1> <h2>DOM Bold Object</h2> <button onclick="myGeeks()"> Submit </button> <p id="sudo"></p> </body> </html> |
Output:
Before Clicking on Button:

After Clicking on Button:

Supported Browsers: The browser supported by DOM Bold Object are listed below:
- Google Chrome
- Internet Explorer
- Firefox
- Opera
- Safari
Recommended Posts:
- HTML | DOM Object Object
- HTML | DOM DFN Object
- HTML | DOM DD Object
- HTML | DOM li Object
- HTML | DOM Div Object
- HTML | DOM S Object
- HTML | DOM Kbd Object
- HTML | DOM Map Object
- HTML | DOM Nav Object
- HTML| DOM Ins Object
- HTML | DOM BR Object
- HTML | DOM DT Object
- HTML | DOM dl Object
- HTML | Object tag
- HTML DOM Aside Object
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.



