How to add a tooltip on an image with HTML?

Spread the love

Sometimes, we want to add a tooltip on an image with HTML.

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

How to add a tooltip on an image with HTML?

To add a tooltip on an image with HTML, we set the title attribute.

For instance, we write

<img
  src="https://picsum.photos/200/300"
  alt="alternative text"
  title="this will be displayed as a tooltip"
/>

to set the title attribute to the tooltip text.

Then we’ll see the tooltip when we hover on the image.

Conclusion

To add a tooltip on an image with HTML, we set the title attribute.

Leave a Reply

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