ARIA attribute that references other elements to compose an accessible name.
aria-labelledby is ARIA's most flexible labeling method. Instead of providing label text directly (like aria-label), it references other elements that contain the labeling text. This creates dynamic, reusable, and contextually rich accessible names.
Think of aria-labelledby as pointing to existing content and saying "use that text as my label." This approach is powerful because it keeps visual and accessible names synchronized automatically – when the referenced text changes, the accessible name updates too.
This makes aria-labelledby perfect for complex interfaces where labels come from headings, multiple text sources, or dynamic content that needs to stay in sync.
aria-labelledby excels in scenarios where aria-label falls short:
Form Sections with Headings: ```html
Complex Multi-Part Labels: ```html Temperature Celsius ```
Data Tables with Dynamic Headers: ```html
Modal Dialogs: ```html
Tab Interfaces: ```html
The Key Advantage: Visual text and accessible names stay synchronized automatically. Change the heading text, and the accessible name updates without touching the ARIA attributes.
Both create accessible names, but they work differently:
Use aria-labelledby when: - Label text exists elsewhere on the page - You need multi-part labels from different elements - Labels should stay synchronized with visible text - Working with headings, captions, or existing content - Building reusable components with dynamic labels
Use aria-label when: - Label text doesn't exist elsewhere - You need simple, static labels - Working with icon-only buttons - Overriding confusing visible text - Labels won't change frequently
Precedence Rules: aria-labelledby overrides aria-label. If both exist, screen readers use aria-labelledby and ignore aria-label completely.
Example Comparison: ```html
Edit John Smith profile ```
The aria-labelledby version is more flexible – change the user name anywhere, and the button label updates automatically.
aria-labelledby supports sophisticated labeling patterns:
Multiple ID References: ```html
Self-Referencing Labels: ```html
Dynamic Content Labels: ```html 3 items in shopping cart ```
Conditional Labels: ```javascript // JavaScript can dynamically change which elements provide the label const button = document.getElementById('action-btn'); if (isEditing) { button.setAttribute('aria-labelledby', 'save-text user-name'); } else { button.setAttribute('aria-labelledby', 'edit-text user-name'); } ```
Cross-Component Labels: ```html ```
These mistakes break aria-labelledby functionality:
Invalid ID References: ```html
Close ```
Empty Referenced Elements: ```html ```
Hidden Referenced Elements: ```html ```
Circular References: ```html
Overly Complex References: ```html ```
Missing Fallbacks: ```html ```
Framework-Specific Issues: In React, Vue, or Angular, ensure referenced IDs exist when components mount and persist through re-renders.
aria-labelledby requires careful testing since it depends on element relationships:
Browser DevTools Testing: - Chrome: Inspect → Accessibility panel → shows computed accessible name - Firefox: Inspect → Accessibility → displays name calculation - Safari: Web Inspector → Accessibility → name and description
Screen Reader Verification: - Navigate to labeled element and listen to announcement - Verify all referenced text is included in correct order - Test with multiple screen readers (NVDA, JAWS, VoiceOver) - Check that label updates when referenced content changes
Automated Testing: ```javascript // Test that aria-labelledby references exist const button = document.querySelector('[aria-labelledby]'); const labelIds = button.getAttribute('aria-labelledby').split(' '); labelIds.forEach(id => { const labelElement = document.getElementById(id); assert(labelElement, `Referenced element #${id} must exist`); assert(labelElement.textContent.trim(), `Element #${id} must have text content`); }); ```
Dynamic Content Testing: - Change referenced text and verify label updates - Test component mounting/unmounting scenarios - Verify labels work after DOM manipulation - Check behavior with single-page app navigation
Manual Checklist: - All referenced IDs exist and are unique - Referenced elements contain meaningful text - Label makes sense when all parts are combined - Label updates when referenced content changes - No circular or self-referencing loops (except intentional self-reference)
Performance Considerations: aria-labelledby requires DOM queries to resolve references. In large documents, excessive use can impact performance.
WebAbility provides comprehensive support for aria-labelledby implementation and maintenance:
Automatic Validation: - Detects broken ID references in aria-labelledby attributes - Identifies empty or hidden referenced elements - Flags circular reference patterns that confuse screen readers - Monitors dynamic content for broken label relationships - Validates that referenced elements contain meaningful text
Smart Suggestions: - Recommends aria-labelledby over aria-label when appropriate text exists - Suggests optimal ID reference patterns for complex labels - Identifies opportunities to consolidate redundant labeling - Provides templates for common labeling scenarios - Offers guidance on multi-part label construction
Framework Integration: - React/Vue/Angular component analysis for proper ID management - Detection of component lifecycle issues affecting label references - Integration with state management for dynamic label updates - Support for component libraries and design systems - Automated testing for label reference integrity
Performance Optimization: - Identifies excessive aria-labelledby usage that impacts performance - Suggests caching strategies for frequently referenced elements - Optimizes DOM queries for label resolution - Monitors label calculation performance in large documents - Provides alternatives for performance-critical scenarios
Maintenance Support: - Tracks label reference relationships across site updates - Alerts when referenced elements are removed or modified - Provides impact analysis for content changes affecting labels - Maintains label consistency across component updates - Offers migration tools for label refactoring
Quality Assurance: - Screen reader testing with actual assistive technology - User testing with people who rely on accessible names - Cross-browser compatibility testing for label resolution - Performance testing for label calculation overhead - Accessibility expert review of complex labeling strategies
WebAbility ensures your aria-labelledby implementation is robust, maintainable, and provides clear, meaningful labels that enhance the user experience for everyone who relies on assistive technology.
Join over 1 million websites using WebAbility to ensure digital accessibility compliance and provide equal access to all users.
Supplemental help text associated with an element, often via aria-describedby, that provides additional guidance beyond the accessible name.
An area of the page that notifies assistive technologies about dynamic updates. Use sparingly with polite or assertive announcements.
Page sections identified by semantic elements or ARIA roles (main, navigation, complementary, banner, contentinfo) for quick navigation.
This glossary is continuously improved and maintained by WebAbility to advance accessible design and development.Contact us to suggest improvements or report issues.