Open In App

HTML <b> Tag

Improve
Improve
Improve
Like Article
Like
Save Article
Save
Share
Report issue
Report

The <b> tag in HTML is for making text bold without adding extra importance. Text within <b> displays in a bold style. 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, just makes text appear bold. 

As per the HTML5 specification, the <b> tag should be used as a last option to resort to when no other tag is more appropriate. The HTML5 specification states that headings should be depicted by the <h1> to <h6> tags, for emphasized text, it must be depicted by the <em> tag & similar, and the important text by the <strong> tag, & for marked/highlighted text, it should be denoted with the <mark> tag.

Syntax

<b> 
      Contents...
</b>

Accepted Attributes

This is a Global attribute, Event Attributes, and can be used on any HTML element.

Note: We can bold the text by 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.

HTML




<!DOCTYPE html>
<html>
 
<body>
    <h1>GeeksforGeeks</h1>
    <h3>HTML b tag</h3>
    <p>
        A <b>Computer Science portal</b> for geeks.
        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.

HTML




<!DOCTYPE html>
<html>
 
<body>
    <h1>GeeksforGeeks</h1>
    <h3>HTML b tag</h3>
 
    <!--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, we have used the CSS font-weight property whose value is set to bold to make the text bold.

HTML




<!DOCTYPE html>
<html>
 
<body>
    <h1>GeeksforGeeks</h1>
    <h3>HTML b tag</h3>
 
    <!--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 
  • Edge 12 and above
  • Internet Explorer 
  • Microsoft Edge
  • Firefox 1 and above
  • Opera 
  • Safari 


Last Updated : 11 Dec, 2023
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads