Dremendo Tag Line

Add Bold Tag to Your Webpage

Working with Text

In this lesson, we will learn how to use the bold tag in HTML and its attributes.

What is Bold Tag in HTML

The bold tag of HTML is used to make the text bold. It is a simple tag that is used to add emphasis to the text. A bold tag is used to highlight important words, headings, or phrases on a web page. The bold tag is one of the most commonly used tags in HTML.

The syntax for the bold tag is straightforward. It requires an opening and closing bold tag, and the text that needs to be bold is placed between these two tags.

video-poster

Here's an example of how to use <b> tag in HTML:

Example

<!doctype html>
<html>

<head>
	<meta charset="utf-8">
	<title>Bold Tag Example</title>
</head>

<body>
	<p>HTML stands for <b>HyperText Markup Language</b>. It is the standard language for creating the <b>content and structure</b> of web pages and web applications.</p>
</body>

</html>

Attributes of Bold Tag

Here are the attributes we can use with the bold tag:

  • id
  • class
  • style
  • title

id

The id attribute is used to assign a unique name to an element on a web page. We can assign an id to the bold tag and use it to apply a specific style to that particular tag.

Example

<p>This is a <b id="btext">bold</b> text.</p>

In the above example, we assign an id attribute to the b tag with a value btext. In CSS and JavaScript, we can use the name btext to access the specific b tag whose id value is set to the name btext.

Note: The id attribute can be used on any tag to assign a unique tag name. It must be unique for each tag, meaning we can't use the same id name for another tag in an HTML document.

class

The class attribute is used to define a group of elements and to apply a specific style to that group. We can define a class for the bold tags and use it to apply a specific style to all the bold tags that belong to a particular class.

Example

<p>This is a <b class="info">bold</b> text.</p>
<p>This is another <b class="info">bold</b> text.</p>

In the above example, both b tags have the same class name, info. If any CSS style is applied to the class name info, it will be applied on both b tags.

Note: The class attribute can be used on any tag to assign a group name to the tag.

style

The style attribute can be used to apply inline css styles to the bold tag. We will learn how to apply inline css style using the style attribute later in our CSS tutorial.

Example

<p>This is a <b style="color: red">bold</b> text.</p>

The style="color: red" will change the color of the bold tag to red color.

title

The title attribute can be used to add a tooltip or additional information to the bold tag, which will only appear when the user places the mouse cursor on the bold text.

Example

<p><b title="HyperText Markup Language">HTML</b> is the standard language for creating the content and structure of web pages and web applications.</p>