If you find this helpful, please click the Google Button to the left, if it is white, to make it turn blue or red. Thank you! (It also helps find this page again more easily.) |
The <b> Tag in HTML 5
The <b> tag indicates that a bold font should be used to display the content. Text in bold is not necessarily considered to have any increased importance. The b element is one of the phrase elements in HTML.
Alternatives to the <b> tag for bold text
The <strong> tag can also be used to display text in bold, but also implies increased importance of the text.
<b> Bold Tag Syntax
Rules for coding HTML b
elements
<body> ... ... phrasing content expected ...<b>... phrasing content ...</b>... ... </body>
Rules for coding HTML b
elements
Make sure you understand the difference between a tag and element and are familiar with the definitions of namespace and other HTML terms.
- Code the b element for bold text where phrasing content is expected.
- Begin the b element with a starting <b> tag. The element name uses lower case letters and should be in the HTML namespace, which it will pick up automatically from the
xmlns
attribute on the <html> tag. - Include any HTML global attributes on the <b> tag as appropriate.
- Inside the b element, between the starting
<b>
tag and the ending</b>
tag, code the inner HTML phrasing content with the text that is to appear in bold. - End the b element with a matching
</b>
closing tag.
Content Model
Content of the b element
The content of the b element can include HTML comments, text content and only those HTML tags that can be used in phrasing content.
<b> Tag Attributes
Attributes of the <b> tag
global attributes | The only attributes that can be coded on the <cite> tag are the common HTML attributes. |
<b> Bold Tag Examples
Examples of the b
tag in HTML 5
Combining bold with other styles
If you try to underline bold text by coding the style
attribute on the <b> tag, the underline will also be bold:
<b style="text-decoration: underline">This Bold Text Has A Bold Underline Style Also</b>
To create bold text without a bold underline, the underline style must be coded on a separate element. With two different elements, the underline color can also be set independently of the text color.
<span style="text-decoration: underline; color: red"> <b style="color: black">This Bold Text Has A Thin Red Underline Style</b> </span>
The style
property is coded on the <b> tag to change the text color back to black since otherwise it would inherit the red color from the parent <span> tag.
Changes in HTML 5 - <b> Tag
What's new in HTML 5
Differences between HTML 5 and earlier versions of HTML
The 2000-2010 Recommendations from the W3C HTML Working Group defined the HTML namespace for the b element type name along with the names of all HTML element types. In older (pre-2000) versions of HTML, element type names were not associated with a namespace.