HTML <b> Tag
The HTML <b>
tag is used to create a 'b' element, which represents bold text in an HTML document.
The <b>
tag should be used to markup text as bold without conveying any extra importance, for example in article abstracts, where the beginning of an article is set in bold text. It should not be used to convey extra importance. To convey extra importance, use the <strong>
tag. To emphasize text, use the <em>
tag.
Syntax
The <b>
tag is written as <b>
</b>
with the text to be bold inserted between the start and end tags.
Like this:
Examples
Product Names
Here's an example of using the <b>
element to mark up product names in a review of two products.
Article Lede
Here's an example of using the <b>
element to mark up the opening paragraph of an article.
An article lede (or lead) is typically used in conjunction with the headline or title. It precedes the main body of the article, and it gives the reader the main idea of what the story is about.
Journalistic ledes emphasize grabbing the attention of the reader, whereas, ledes in essays summarize the outline of the argument and conclusion that follows in the main body of the essay.
<b>
vs <strong>
vs <em>
Remember, the <b>
should not be used to convey extra importance. To convey extra importance, use the <strong>
tag.
Also, the <b>
should not be used to convey emphasis. To convey emphasis, use the <em>
tag.
Below are examples of the correct usage of each of these tags.
Attributes
Attributes can be added to an HTML element to provide more information about how the element should appear or behave.
The <b>
element accepts the following attributes.
Attribute | Description |
---|---|
None |
Global Attributes
The following attributes are standard across all HTML elements. Therefore, you can use these attributes with the <b>
tag , as well as with all other HTML tags.
accesskey
autocapitalize
class
contenteditable
data-*
dir
draggable
hidden
id
inputmode
is
itemid
itemprop
itemref
itemscope
itemtype
lang
part
slot
spellcheck
style
tabindex
title
translate
For a full explanation of these attributes, see HTML 5 global attributes.
Event Handlers
Event handler content attributes enable you to invoke a script from within your HTML. The script is invoked when a certain "event" occurs. Each event handler content attribute deals with a different event.
onabort
onauxclick
onblur
oncancel
oncanplay
oncanplaythrough
onchange
onclick
onclose
oncontextmenu
oncopy
oncuechange
oncut
ondblclick
ondrag
ondragend
ondragenter
ondragexit
ondragleave
ondragover
ondragstart
ondrop
ondurationchange
onemptied
onended
onerror
onfocus
onformdata
oninput
oninvalid
onkeydown
onkeypress
onkeyup
onlanguagechange
onload
onloadeddata
onloadedmetadata
onloadstart
onmousedown
onmouseenter
onmouseleave
onmousemove
onmouseout
onmouseover
onmouseup
onpaste
onpause
onplay
onplaying
onprogress
onratechange
onreset
onresize
onscroll
onsecuritypolicyviolation
onseeked
onseeking
onselect
onslotchange
onstalled
onsubmit
onsuspend
ontimeupdate
ontoggle
onvolumechange
onwaiting
onwheel
Most event handler content attributes can be used on all HTML elements, but some event handlers have specific rules around when they can be used and which elements they are applicable to.
For more detail, see HTML event handler content attributes.