How to fix: Required attribute "alt" not specified

Most Likely Cause and Fix

Your markup contains an <img /> element that lacks the required alt attribute:

<img src="http://example.com" … />

Add an alt attribute to each <img /> element where missing:

<img src="http://example.com" alt="Text alternative when image is not available" … />

What This Error Means

There is a defined set of attributes for each HTML element. Some are required for your markup to be considered valid.

You have omitted the required alt attribute on an element that requires it.

How To Fix It

The specific error message you encountered will refer to a line and column number. This will guide you to the exact point in your markup to which the error relates.

For images

You've most likely forgotten to add an alt attribute to an <img /> element:

<img src="http://example.com" … />

Add an alt attribute to each <img /> element where missing:

<img src="http://example.com" alt="Text alternative when image is not available" … />

In general

Find the relevant element and add the missing alt attribute.

Discuss, Comment and Improve

Did this help you? Can this page be improved? Let us know!

comments powered by Disqus