What is the use of title attribute in HTML?
Overview
We use the title attribute in HTML to specify the extra information about the element. The additional information appears whenever the mouse hovers over the element.
Note: All HTML
tagssupport this attribute.
Syntax
We'll use the syntax below to add the title attribute to an HTML element:
<element title='text'>
Here element can be any sort of HTML tag , for example, <p>,<a> and <img>, and others.
Example 1
The following code snippet illustrates the use of the title attribute in the h3 tag of HTML:
Explanation
- Line 5: This line uses the
titleattribute in a<h3>tag. The result is shown in the output tab of the widget above. - The example above shows that the additional information appears when we hover the mouse over the
<h3>tag.
Example 2
Similarly, we can make use of the title attribute on <img> tag as well. This is depicted by the code snippet below:
Explanation
- Line 5: This line depicts the use of
titleattribute in an<img>tag and sets it to the value ofEducative Inc.
This answer summarizes the primary use of the title attribute along with code snippets to demonstrate its functionality.
Free Resources
Copyright ©2026 Educative, Inc. All rights reserved