Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
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 −

Advertisements