HTML <b> Element

Publish in HTML Tutorial el 23/05/2025 17:08

The HTML <b> element is used to draw attention to text without implying any added importance or emphasis. It simply makes the text appear in boldface. Unlike <strong>, which indicates semantic importance, <b> is purely presentational.


Basic Syntax

Here's how the <b> element is written in HTML:

Rendered result: This text will be bold


When to Use <b>

  • Highlighting product names in reviews
  • Drawing attention to key words in summaries
  • Styling lead sentences in paragraphs
  • Formatting dictionary-style entries
  • Creating visual contrast without semantic meaning


Examples

1. Basic Bold Text

The simplest use case for the <b> element:

Play Code


2. Bold in List Items

Highlighting key parts of list items:

Play Code


3. Dynamic Bold with JavaScript

Using JavaScript to toggle bold formatting:

Play Code


4. Bold in Table Headers

Using <b> to emphasize table headers:

Play Code


5. JavaScript Mouseover Bold Effect

Making text bold on mouseover with JavaScript:

Play Code


Tips and Tricks

  • Use CSS font-weight: bold; instead when you need to apply bold styling to multiple elements for better performance.
  • Don't overuse <b> as it can make text harder to read when overdone.
  • Combine <b> with other elements like <i> for bold italic text.
  • Remember that screen readers don't emphasize <b> elements differently unless CSS is applied.
  • For semantic importance, prefer <strong> instead of <b>.

Browser Support

The <b> element is supported by all browsers, including:

  • Chrome (all versions)
  • Firefox (all versions)
  • Safari (all versions)
  • Edge (all versions)
  • Internet Explorer (all versions)
  • Opera (all versions)

También te puede interesar

HTML <style> Element
HTML <style> Element

The <style> HTML element contains style information for a document, or part of a document. ...

HTML <strong> Element
HTML <strong> Element

The <strong> element is used to indicate that its content has strong importance, seriousnes...

HTML <span> Element
HTML <span> Element

The <span> element is an inline container used to mark up a part of a text or document. Unl...

HTML <source> Element
HTML <source> Element

The <source> element is used to specify multiple media resources for media elements like &l...

HTML <small> Element
HTML <small> Element

The <small> element is used to represent side-comments and small print, typically for discl...

HTML <section> Element
HTML <section> Element

HTML <section> Element: The Complete Guide The <section> element is a semantic HTML ...