Most developers know the basics of Alt Text for images. But when building modern apps with complex UI, alt text alone is not enough. Thatβs where ARIA attributes come in.
Letβs go deeper.
1οΈβ£ Alt Text β For Image Meaning
Alt text (alt) is specifically designed for images.
It tells screen readers what the image represents.
<img src="dashboard-chart.png" alt="Line chart showing user growth from January to June">
When to use it
β Product images
β Blog images
β Icons that convey meaning
β Charts or graphs
If the image is purely decorative, use an empty alt.
<img src="divider.png" alt="">
This tells screen readers to ignore it.
2οΈβ£ The Problem Developers Face
In real projects we often have:
- Icon buttons
- SVG icons
- Custom components
-
divbuttons - Complex UI
Example:
<button>
<svg>...</svg>
</button>
A screen reader will just say:
"button"
No context.
3οΈβ£ aria-label β Adding Meaning to UI
aria-label provides accessible text for elements that don't have visible text.
<button aria-label="Close modal">
<svg>...</svg>
</button>
Now screen readers say:
"Close modal button"
4οΈβ£ Common Real-World Cases
Icon Button
<button aria-label="Search">
<svg>...</svg>
</button>
Social Media Icons
<a href="#" aria-label="Open Twitter profile">
<svg>...</svg>
</a>
Input Without Visible Label
<input type="text" aria-label="Search products">
5οΈβ£ aria-labelledby (Better for Dynamic UI)
Instead of writing text again, reference an existing element.
<h2 id="modal-title">Delete Account</h2>
<button aria-labelledby="modal-title">
Confirm
</button>
Screen readers read:
"Delete Account Confirm button"
This keeps content consistent and maintainable.
6οΈβ£ Accessibility Rule Many Developers Miss
π Always use semantic HTML first.
Bad example:
<div onclick="openMenu()">Menu</div>
Better example:
<button>Menu</button>
ARIA should enhance accessibility, not replace proper HTML.
7οΈβ£ Quick Developer Checklist
Before shipping UI:
β Every meaningful image has alt text
β Icon-only buttons have aria-label
β Inputs have labels or aria-label
β Use semantic elements like button, nav, header, main
β Decorative images use alt=""
π‘ Accessibility is not just about compliance.
It's about building products everyone can use.
Good developers make things work.
Great developers make things accessible.
Top comments (0)