- Home
- /
- Tutorials
- /
- HTML Tutorial
- /
- HTML <b> Tag
HTML Tags
HTML <b> Tag
The b tag makes text bold to draw the eye, without saying the text is more important. If the words really matter more, the strong tag is the one you want.
b or strong?
Both look bold, but they say different things:
<strong>means "this is important". Use it for warnings and key points: "Do not unplug the device."<b>means "look at this", without extra importance: a product name in a review, keywords in a summary, the first words of an article.
If you only want bold for styling, CSS font-weight: bold is often the cleanest choice. The full comparison is in the strong tag lesson.
Syntax
html
<b>Bold text here</b>There are no special attributes, only the global ones like class, id, style and title.
Example
html
<!DOCTYPE html>
<html>
<head>
<title>B Tag Example</title>
<style>
.highlight {
color: #29AB87;
font-weight: bold;
background-color: #f0f0f0;
padding: 2px 4px;
border-radius: 4px;
}
</style>
</head>
<body>
<h1>HTML <b> Tag Example</h1>
<p>
The <b> tag makes text <b class="highlight" id="keyword" title="Bold Text">bold</b> without changing its meaning.
</p>
<p>
Example: This is a <b>bold statement</b> in a paragraph.
</p>
</body>
</html>The word "bold" in the first paragraph is bold and green because of its class, and "bold statement" in the second paragraph is plain bold.
Browser Support
Chrome | Edge | Firefox | Safari | Opera | IE9+ |
|---|---|---|---|---|---|
| Yes | Yes | Yes | Yes | Yes | Yes |
Good to know
<b>is an inline element, so it sits inside a line of text and does not start a new line.- Do not use
<b>to make headings. A bold line is not a heading for search engines or screen readers; use<h2>or<h3>. - Screen readers usually read
<b>and<strong>the same way, so do not rely on bold alone to warn people about something.
HTML <b> Tag exercises
Bold a keyword
Write this paragraph with only the word HTML in bold, without making it more important: The HTML language describes structure.
Result
Check your answer to see it here.
