Categories
HTML

How to add a tooltip to a div with HTML?

Spread the love

Sometimes, we want to add a tooltip to a div with HTML.

In this article, we’ll look at how to add a tooltip to a div with HTML.

How to add a tooltip to a div with HTML?

To add a tooltip to a div with HTML, we set the title attribute.

For instance, we write

<div title="This is my tooltip" class="visible"></div>

to set the title attribute to the tooltip text.

Then the tooltip text would show.

Conclusion

To add a tooltip to a div with HTML, we set the title attribute.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *