The alt attribute
The alt
attribute is not a required attribute for the <img>
tag, but it's very important. It provides an alternative text for the picture if the picture doesn't load for some reason.
The alt
attribute is crucial for several reasons. First, it's essential for
SEO and missing it makes you fail the W3C validation test.[1] Second, it's the only way people using screen readers can know what's in that picture that they can't see.
Use this attribute every time!