The alt attribute is for images only
alt attribute is used to provide alternate text for HTML elements that use images. The alternate text is used when an image cannot be seen (because the user can’t see) or when it cannot be rendered (because the display of images is disabled, the browser does not support images, the image is corrupt, the image’s URL is incorrect, etcetera).
In HTML 4.01 Strict the
alt attribute is valid only for the following three elements:
alt attribute is only relevant for
input elements (graphical submit buttons) that also have a
type attribute whose value is
area elements, the
alt attribute is required. It is optional for
input elements though alternative text should always be provided for graphical submit buttons.
Sometimes I see people use
alt attributes for other elements, such as links. I think in most such cases the author is really looking for the
title attribute, which can be used to provide additional information about an element. More detailed descriptions of these attributes and their use can be found in The alt and title attributes.
This post is a Quick Tip. Background info is available in Quick Tips for web developers and web designers.
This article has been translated into the following languages:
- Previous post: It’s “class”, not “CSS class”
- Next post: WCAG 2.0 recommends using luminosity contrast ratio to check colour contrast
Subscribe / follow
- Creative Web Designer at ADP / Autotegrity (Cambridge, MA, Ma, US)
- UI Designer / Frontend Developer at Cosmic (Santa Cruz, CA, Ca, US)
- UX/Creative Media Designer at Ultimate Fighting Championship (UFC) (Las Vegas, NV, Ne, US)
- Java Software Developer eCommerce at arvato Systems North America (New York, NY; San Francisco, CA; Chicago, IL, Il, US)
DreamHost web hosting
Use the promo code 456BEREASTREET3 to save USD 20 when you sign up for DreamHost