Open In App
Related Articles

HTML <b> Tag

Improve Article
Improve
Save Article
Save
Like Article
Like

The <b> tag in HTML is used to specify the bold text without any extra importance. The text is written within <b> tag display in bold size. You can do that by using font-weight: bold; property in CSS. It is a container tag that contains an opening tag, content & closing tag. There is a similar tag, <strong> tag that is the parsed tag and used to show the importance of the text & has a similar effect on content. 

As per the HTML5 specification, the <b> tag should be used as a last option to resort when no other tag is more appropriate. The HTML5 specification states that for headings, it should be depicted by the <h1> to <h6> tags, for emphasized text, it must be depicted by the <em> tag & similar wise, 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, and can be used on any HTML element.

Example 1: This simple code example illustrates highlighting the text by making it as 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 illustrates 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 : 05 Jul, 2023
Like Article
Save Article
Similar Reads
Related Tutorials