How to add a tooltip to a div with HTML?

Spread the love

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

For instance, we write

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

to add a div.

Then we set its title attribute to the tooltip text.

We see the tooltip when we hover over the div.

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 *