W3docs

HTML <b> tag

The <b> tag is used to highlight in bold the part of the text, which we want to make more obvious for the user

The HTML <b> tag is used to render a part of the text in bold to make it stand out. The <b> tag only changes the visual appearance; it carries no semantic meaning (including for search engines).

Tip

In HTML5, the <b> tag is intended for non-semantic stylistic emphasis, such as marking keywords, product names, or UI labels, rather than as a fallback for other tags.

Avoid using the <b> tag for titles and headings. Instead, you can use the <h1><h6> tags. It is preferable to use the <b> tag for marking keywords, product names, or other spans of text where semantic importance is not required.

Syntax

The <b> tag comes in pairs. The content is written between the opening ( <b> ) and closing ( </b> ) tags.

Example of the HTML <b> tag:

Example of the HTML <b> tag|W3Docs

<!DOCTYPE html>
<html>
  <head>
    <title>Title of the document </title>
  </head>
  <body>
    <p><b>This section of the text </b> has been rendered in bold,</p>
  </body>
</html>

Result

b tag example

The default appearance of the <b> element is bold, but you can change it using CSS. The CSS font-weight property can also be used to set bold text.

Example of the font-weight property for making the text bold:

<!DOCTYPE html>
<html>
  <head>
    <title>Title of the document </title>
    <style>
      .bold-text {
        font-weight: 700;
      }
    </style>
  </head>
  <body>
    <p>
      <span class="bold-text">This section of the text </span> 
      has been rendered in bold.
    </p>
  </body>
</html>

<b> vs <strong>

Both the <b> and <strong> elements render text in a bold typeface. The difference is that the <strong> tag indicates text of greater importance, while the <b> tag is purely presentational and carries no semantic meaning. For stylistic bold text without semantic weight, you can also use the bold value of the CSS font-weight property.

Attributes

The <b> tag supports Global Attributes and Event Attributes.

How to apply a global attribute to an HTML <b> tag

<p>The <b class="highlight" title="Important keyword">keyword</b> is emphasized here.</p>

Practice

Practice

What is the function of the HTML <b> tag?