How to create a text description for an image in HTML

Updated: 07/13/2023 by Computer Hope
Fictional HTML keyboard key in place of Enter key.

In HTML (HyperText Markup Language), adding a "title" attribute to the img src tag displays a message for the image as shown in the below code.

Example img HTML code

The following code displays "Visit Computer Hope" when a mouse hovers over the image in all browsers. We also used the "alt" attribute to describe the image. Some browsers also use this attribute as the hover text. We recommend using the "alt" attribute to describe the image for search engines and the visually impaired and the "title" attribute for the hover text.

<img src="https://www.computerhope.com/chguy.gif" alt="Computer Hope guy holding Computer Hope logo" title="Visit Computer Hope">

Below is an example of the above code in action. If you hover your mouse over the picture, it displays the "Visit Computer Hope" message.

Note

Realize that hovering a mouse cursor over an image works best on a desktop computer. If your audience is mostly smartphone users, they cannot hover their finger over an image and most will not tap and hold the image.

Example

Computer Hope guy holding the Computer Hope logo