Altcademy - a Forbes magazine logo Best Coding Bootcamp 2023

How to make text bold in HTML

Unraveling the Basics

Let's dive straight into the heart of the matter. We will be discussing the method of making text bold in HTML. HTML, or HyperText Markup Language, is the standard language used to create web pages. Don't get intimidated by the fancy name; think of it as the skeleton of a webpage, giving it structure and form.

The Importance of Bold Text

Before we start coding, it's essential to understand why we need bold text in the first place. Bold text stands out on a page, drawing the reader's attention to that specific piece of information. It's like a flag on a large field, signaling to the reader that 'Hey, this is important!'.

The Mighty HTML Tags

HTML uses 'tags' to create elements on a webpage. Think of tags as the different brushes an artist uses to paint a picture. Just like how each brush has a specific purpose, each tag in HTML has a unique function.

To make a text bold in HTML, we use the <b> tag or the <strong> tag.

Using the <b> Tag

The <b> tag is the simplest way to make text bold in HTML. Here's how it works:

<b>This is a bold text.</b>

When you run this code in a web browser, it displays the text as This is a bold text.

Let's break it down. The <b> and </b> are opening and closing tags, respectively. They are like a start and finish line for a race. The text that needs to be bolded is the 'runner' that goes in between these two 'lines'. The web browser reads this code and knows to display the text between these tags in bold.

Using the <strong> Tag

Another tag that you can use to make text bold in HTML is the <strong> tag. Here's an example:

<strong>This is a strong text.</strong>

When you run this code in a web browser, it displays the text as This is a strong text.

Much like the <b> tag, the <strong> tag also has opening and closing tags, and the text that needs to be bolded goes in between them.

The <b> Tag vs. The <strong> Tag

You might be wondering, if both tags make the text bold, what's the difference between them? Well, while the end result is the same, the significance they carry for the web browser is different.

The <b> tag merely changes the visual appearance of the text to bold. It's like changing the color of a car; it doesn't affect how the car functions.

On the other hand, the <strong> tag indicates that the enclosed text is of high importance. It's like adding a turbo engine to a car; it changes the car's performance. Some browsers and assistive technologies (tools that assist people with disabilities in using technology) may treat this text differently, like reading it out louder in a screen reader.

Conclusion

In the end, choosing between the <b> and <strong> tag depends on your specific needs. If you just want the text to appear bold, use the <b> tag. But if you want to signify that the text holds high importance, use the <strong> tag.

Remember, coding is not just about getting the right output. It's also about communicating effectively with the web browser and the users who interact with your web pages. Happy coding!