Is the alt Attribute Required on the img HTML Element?

Find out if alt attribute on img tag is mandatory

The alt attribute on the <img /> HTML tag is not mandatory. However, it is considered a good practice to add it as it provides some good benefits, such as:

  • Improving accessibility;
  • Helping browsers substitute invalid, broken or unsupported images with the alt text;
  • Providing context to search engine crawlers (which can in-turn improve SEO).

If you don't add the alt text for images, then the image information would be inaccessible, for example, to:

  • People with visual impairments;
  • People who have turned off images in their browsers;
  • Non-visual browsers (such as screen readers);
  • Visual browsers, for example, when the image can't be displayed;
  • Search engine crawlers, bots, etc.

There are instances where you can specify an empty alt attribute (i.e. alt=""). This indicates that the image is not an important part of the content. For example, it could be the case when the image is used as a decoration or a tracking pixel. In such instances, for example, a visual browser may choose to hide the broken image icon.


Hope you found this post useful. It was published . Please show your love and support by sharing this post.