Sometimes, we want to add a tooltip to a span element with HTML.
In this article, we’ll look at how to add a tooltip to a span element with HTML.
How to add a tooltip to a span element with HTML?
To add a tooltip to a span element with HTML, we set the title
attribute.
For instance, we write
<span title="My tip">text</span>
to add the title
attribute and set its value to the tooltip text.
Then when we hover over the span, ‘My tip’ is displayed in a tooltip.
Conclusion
To add a tooltip to a span element with HTML, we set the title
attribute.