Add Strong Tag to Your Webpage
Working with Text
In this lesson, we will learn how to use the strong tag in HTML and its attributes.
What is Strong Tag in HTML
The strong tag is an HTML tag used to give extra emphasis to a particular text on a web page. This tag is used to highlight the importance of the text and make it more noticeable to the readers.
The syntax for the strong tag is straightforward. It requires an opening and closing strong tag, and the text that needs to be emphasized is placed between these two tags.
Here's an example of how to use <strong> tag in HTML:
Example
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Strong Tag Example</title>
</head>
<body>
<p><strong>Dennis Ritchie</strong> is an American computer scientist known as the father of the <strong>C programming language</strong>.</p>
</body>
</html>
Difference between Strong Tag and Bold Tag
Many people confuse the strong tag with the bold tag, and sometimes they use them interchangeably. However, there is a significant difference between the two.
The bold tag (<b>) is used to make the text bold, which makes it stand out from the surrounding text. On the other hand, the strong tag (<strong>) is used to give extra importance to the text, making it more noticeable to the readers.
Attributes of Strong Tag
Here are the attributes we can use with the strong 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 strong tag and use it to apply a specific style to that particular tag.
Example
<p>This is a <strong id="stext">strong</strong> text.</p>
In the above example, we assign an id attribute to the strong tag with a value stext. In CSS and JavaScript, we can use the name stext to access the specific strong tag whose id value is set to the name stext.
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 strong tags and use it to apply a specific style to all the strong tags that belong to a particular class.
Example
<p>This is a <strong class="info">strong</strong> text.</p>
<p>This is another <strong class="info">strong</strong> text.</p>
In the above example, both strong tags have the same class name, info. If any CSS style is applied to the class name info, it will be applied on both strong 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 strong tag. We will learn how to apply inline css style using the style attribute later in our CSS tutorial.
Example
<p>This is a <strong style="color: red">strong</strong> text.</p>
The style="color: red" will change the color of the strong tag to red color.
title
The title attribute can be used to add a tooltip or additional information to the strong tag, which will only appear when the user places the mouse cursor on the strong text.
Example
<p><strong title="HyperText Markup Language">HTML</strong> is the standard language for creating the content and structure of web pages and web applications.</p>