Altcademy - a Forbes magazine logo Best Coding Bootcamp 2023

How to bold in HTML

Understanding HTML Tags

Think of HTML tags as the building blocks of any website. They are the essential elements that structure and shape content on a webpage. Imagine you are building a house out of Lego bricks. Each Lego brick represents an HTML tag, and just as you use different shapes and sizes of Lego bricks to create various parts of the house, you use different HTML tags to design different parts of a webpage. One such HTML tag is the <b> tag, which we use to make text bold.

The <b> HTML Tag

The <b> tag in HTML is utilized to visually represent bold text. The text enclosed within the opening <b> and closing </b> tags appears bold on the webpage. Let's look at a simple example:

<p>This is a <b>bold</b> statement.</p>

In this example, the word "bold" will appear in bold font on the webpage, while the rest of the sentence will maintain its normal font weight.

The <strong> HTML Tag

However, there is another tag in HTML that creates a similar visual effect: the <strong> tag. The <strong> tag also makes the enclosed text bold, just like the <b> tag. Here's how it looks:

<p>This is a <strong>bold</strong> statement.</p>

So, you might be wondering, "If the <b> tag and the <strong> tag do the same thing, why do we need two different tags?". Well, there is a subtle but important difference between these two tags.

The Difference Between <b> and <strong>

While both <b> and <strong> tags make the text appear bold, they have different semantic meanings. In a non-programming context, semantics refers to the meaning of words and sentences. In HTML, semantics refers to the meaning of tags and how they are interpreted by browsers and assistive technologies like screen readers.

The <b> tag is purely a visual tag with no additional meaning. It simply makes the text bold. On the other hand, the <strong> tag indicates that the enclosed text has strong importance or seriousness. For example, a screen reader might emphasize the words within the <strong> tag more than the rest of the content, whereas it would read the text within the <b> tag normally.

It's like highlighting a word in a book. When you see a bold word (represented by the <b> tag), you notice that it's bold, but you don't necessarily know why it's bold. But when you see a word highlighted (represented by the <strong> tag), you understand that the author wants to emphasize that word or phrase.

When to Use <b> and <strong>

When deciding whether to use the <b> tag or the <strong> tag, think about the purpose of making the text bold. If you want to make text bold for stylistic reasons, use the <b> tag. But if you're making text bold to indicate importance or seriousness, use the <strong> tag.

Here's an example:

<p>The <b>big, bad wolf</b> huffed and puffed and blew the house down.</p>
<p><strong>Warning:</strong> Don't open the door for strangers!</p>

In the first sentence, "big, bad wolf" is bold for stylistic reasons, so the <b> tag is used. In the second sentence, "Warning" is bold to indicate importance, so the <strong> tag is used.

Conclusion

HTML tags are the fundamental elements that shape a webpage. While the <b> and <strong> tags may seem similar, understanding their semantic differences is crucial for creating accessible and meaningful web content. Remember, the <b> tag is for stylistic bolding, and the <strong> tag is for indicating importance. By carefully choosing your HTML tags, you can ensure your webpages are both visually appealing and semantically meaningful.