HTML <b> Tag
The <b> tag in HTML is for making text bold without adding extra importance. It’s a container tag with an opening, content, and closing. It’s similar to <strong>, which highlights text for importance, but <b> doesn’t add significance.
According to the HTML5 specification, the <b> tag should only be used when no other tag is suitable. Headings should use <h1> to <h6>, the emphasized text should use <em>, the important text should use <strong>, and the highlighted text should use <mark>.
Syntax:
<b>
Contents...
</b>
Accepted Attributes
This is a Global attribute, Event Attributes, and can be used on any HTML element.
Note: We can also bold the text using the font-weight: bold property in CSS.
Example 1: This simple code example illustrates highlighting the text by making it bold text in HTML.
<!DOCTYPE html>
<html>
<body>
<h3>HTML b tag</h3>
<p>
A
<b>Computer Science portal</b>
for Beginner. It contains well written,
well thought and well explained
<b>computer science and programming articles.</b>
</p>
</body>
</html>
Output:
Example 2: In this example, we have used the <b> tag & <p> tag to illustrate the difference in the text appearance & their sizes.
<!DOCTYPE html>
<html>
<body>
<!--paragraph Tag -->
<p>This is normal paragraph Tag text</p>
<!--bold Tag -->
<b>This is bold Tag text</b>
</body>
</html>
Output:
Example 3: In this example, instead of using b tag we have used CSS font-weight property whose value is set to bold to make the text bold.
<!DOCTYPE html>
<html>
<body>
<!--paragraph Tag -->
<p>This is normal paragraph Tag text</p>
<!--Using CSS in paragraph Tag
for making text bold -->
<p style="font-weight: bold">
This is bold text using CSS
</p>
</body>
</html>
Output:
Supported Browsers
- Google Chrome: 1
- Edge: 12
- Firefox: 1
- Opera: 15
- Safari: 1