Search

How to make non-text elements accessible - some notes

1 views

Why Alt Text Is Essential for Web Accessibility

When a user cannot see a page’s visual content, the only way the information can still reach them is through text. That text must live inside the image element, not just on the surrounding page. The alt attribute is the vehicle that carries that information. It is required by both HTML 4 and XHTML standards, so ignoring it is not just a best‑practice slip; it violates core web‑design rules.

Alt text serves three key purposes. First, it gives screen readers a word or phrase to announce when the image is encountered. Second, it provides a fallback when images are turned off, which many users do for bandwidth or accessibility reasons. Third, it supplies search engines with a readable description, so the image can contribute to SEO and be discovered through image search.

Consider a photo in a travel blog. A sight‑seeing enthusiast who relies on a screen reader will hear “Photo: Eiffel Tower” and instantly understand that the picture is about that landmark. A mobile user with data limits may have the image disabled; the alt text still appears in place, keeping the page coherent. Search crawlers ingest the alt attribute and index the photo under “Eiffel Tower,” helping the article surface in relevant queries. In short, alt text is the invisible bridge that connects visual, textual, and semantic worlds.

When alt text is omitted or left blank, the consequences ripple across the user experience. Screen readers may skip the image entirely or announce an empty space, which can break the flow of a narrative. Users who view the page with images off may see a large gap or an unsightly icon, confusing them about where content is missing. And search engines lose an opportunity to rank that image, reducing traffic potential. A single, well‑crafted alt attribute can therefore have a measurable impact on usability, discoverability, and compliance.

In practice, every non‑text element - images, audio files, videos, image maps, animations, and even decorative spacing - needs an alt attribute or an equivalent descriptor. The challenge is writing alt text that captures the function or meaning of the element without cluttering the experience for those who rely on assistive technologies. The following sections break down how to do that effectively.

Writing Concise, Functional Alt Text

When you’re deciding what to write in an alt attribute, ask yourself: “What is the image’s purpose?” Think in terms of function rather than appearance. For a gallery photo, a brief description of the scene suffices. For a button, the label should mirror the action the button performs. For a navigation link, the alt text should indicate the destination. This approach keeps alt text tight, meaningful, and consistent.

Take an image that acts as a submit button for a search form. The image itself may show a magnifying glass, but the function is “search.” Instead of “image of a magnifying glass,” write alt="Search". When a picture is simply decorative - an ornamental line or a pixel spacer - leave the alt attribute empty or set it to a single space. That tells screen readers to skip it entirely, preventing unnecessary noise.

For photographs of people, it is best to include the person’s name if the image’s purpose is to identify them. If the person is the subject of a news article, the alt text “Photo: Maria Gonzalez” informs the reader who is being discussed. In contrast, a background figure in a complex illustration that does not add to the story should get an empty alt. This strategy balances visibility for sighted users with clarity for assistive‑technology users.

Length matters. While there is no hard technical limit, overly verbose alt attributes can become unwieldy, especially when the text exceeds the width of the image. Long sentences may be read aloud in a single breath, making them hard to parse. A practical rule is to keep alt text to one sentence, or 50–80 characters, whichever is shorter. If a richer description is needed - such as a detailed chart caption - you can add a title attribute or a longdesc link, but keep the alt concise.

It is common to see people include the word “Photo:” or “Image:” at the start of an alt. While this is redundant for most screen readers, it can aid users who view the page with images off, giving them a quick visual cue that the placeholder represents a picture. However, consistency matters; if you decide to prefix every alt with “Photo:” for gallery images, do the same for all gallery photos.

When creating a navigation bar that uses icons, the alt text should state the target page. An icon that leads to a weather forecast page deserves alt="Weather Forecast". If the icon is purely decorative - like a separator line - set the alt to an empty string. This eliminates duplication and keeps the navigation concise for those using screen readers.

Finally, always test alt text with a screen reader. Hearing the description read aloud reveals whether it feels natural, whether it contains unnecessary detail, or whether the context is clear. A practical workflow is: add the alt, run a quick screen‑reader audit, then adjust as needed. This iterative process ensures the alt text truly serves its purpose.

Extending Accessibility: Titles, longdesc, and Other Non-Text Elements

Beyond the alt attribute, other attributes offer layers of context. The title attribute supplies supplemental information that appears as a tooltip when users hover over the image. It is not read by most screen readers by default, so use it sparingly for extra details that do not alter the core meaning.

For example, an image of a historic building might have alt="Photo: The Old Town Hall" and title="The Old Town Hall, built in 1875, located on Main Street." This combination delivers a concise alt for assistive technology and a richer tooltip for sighted users. Keep the tooltip short enough to fit within the window; very long tooltips can become truncated.

When an image contains complex data - such as a detailed graph or an infographic - a full textual description can be placed in a separate HTML page referenced by longdesc. The attribute itself is still optional, but it signals that a deeper explanation exists. A screen reader might provide a link to that page, allowing users to explore the data at their own pace. For instance: <img src="sales.png" alt="Sales Chart" longdesc="sales_chart.html"> This practice preserves page cleanliness while granting advanced users access to the underlying information.

Not all non‑text elements use alt. Audio files, for instance, can be described with a link containing an image that has an alt attribute: <a href="intro.mp3"><img src="audio_icon.png" alt="Play audio: Introduction"></a>. The alt tells the user what the link does. Video elements often use the poster attribute, which can carry an alt via an img wrapper.

Decorative images such as spacer GIFs or decorative line images should always have an empty alt or a single space. For example: <img src="spacer.gif" alt=" ">. This tells assistive technologies to ignore the element entirely. Without this, a screen reader would announce an image placeholder, creating unnecessary clutter.

Company logos also follow a simple rule: alt="Acme Corp logo" for a clickable link, or simply alt="Acme Corp" if it is a decorative banner. Avoid describing the logo’s design; focus on the brand name so that users understand the context.

In practice, many designers adopt a pattern where they prepend a short tag - “Photo:”, “Image:”, or “Icon:” - before the description. This signals the role of the element at a glance. However, consistency is key: use the same convention across the site to avoid confusion.

When you’re unsure whether an image is decorative or meaningful, consider how it changes the page’s meaning. If the image adds information, give it an alt. If it only provides visual interest, leave the alt empty. This decision process keeps the page accessible without overloading users with unnecessary descriptors.

As a final note, the Web Content Accessibility Guidelines (WCAG) recommend providing equivalent alternatives for all non‑text content. By carefully crafting alt text, titles, and longdesc links, you ensure that every user - whether they use a screen reader, a text‑only browser, or a visual screen - receives the same core information.

Suggest a Correction

Found an error or have a suggestion? Let us know and we'll review it.

Share this article

Comments (0)

Please sign in to leave a comment.

No comments yet. Be the first to comment!

Related Articles