Skip to content
Related Articles

Related Articles

Improve Article

HTML <b> Tag

  • Difficulty Level : Basic
  • Last Updated : 21 Sep, 2021

Example: 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:

The <b> tag in HTML is used to specifies 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: 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 2: 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 93.0
  • Internet Explorer 11.0
  • Microsoft Edge 93.0
  • Firefox 92.0
  • Opera 78.0
  • Safari 14.1

Attention reader! Don’t stop learning now. Get hold of all the important HTML concepts with the Web Design for Beginners | HTML  course.




My Personal Notes arrow_drop_up
Recommended Articles
Page :