Compiler Warnings
Svelte’s compiler catches potential accessibility mistakes during development, helping you fix issues before they reach production.Disabling Warnings
If a warning is a false positive for your use case, disable it with a comment:Common Accessibility Warnings
Interactive Elements
Click Events Need Keyboard Support
Warning:a11y_click_events_have_key_events
Visible, non-interactive elements with click handlers must also support keyboard interaction:
Mouse Events Need Focus Events
Warning:a11y_mouse_events_have_key_events
onmouseover and onmouseout must be accompanied by onfocus and onblur:
ARIA Attributes
Required ARIA Properties
Warning:a11y_role_has_required_aria_props
Elements with ARIA roles must have all required attributes:
Supported ARIA Properties
Warning:a11y_role_supports_aria_props
Only use ARIA attributes supported by an element’s role:
Correct ARIA Attribute Types
Warning:a11y_incorrect_aria_attribute_type
ARIA attributes must have the correct value type:
Form Elements
Labels for Form Controls
Warning:a11y_label_has_associated_control
Label tags must be associated with a control:
Images and Media
Alternative Text for Images
Warning:a11y_missing_attribute
Images must have alt text:
Use empty
alt="" for purely decorative images so screen readers skip them.Avoid Redundant Alt Text
Warning:a11y_img_redundant_alt
Don’t include words like “image”, “photo”, or “picture” in alt text:
Captions for Video
Warning:a11y_media_has_caption
Video elements must include captions:
Semantic HTML
Avoid Distracting Elements
Warning:a11y_distracting_elements
Avoid deprecated elements that cause accessibility issues:
Don’t Hide Important Elements
Warning:a11y_hidden
Headings and landmarks shouldn’t be hidden from screen readers:
Proper HTML Structure
Warning:a11y_figcaption_parent, a11y_figcaption_index
<figcaption> must be the first or last child of <figure>:
Focus Management
Avoid Autofocus
Warning:a11y_autofocus
Autofocusing can disorient users:
Positive Tabindex
Warning:a11y_positive_tabindex
Avoid positive tabindex values:
Interactive Roles Must Be Focusable
Warning:a11y_interactive_supports_focus
Elements with interactive roles need tabindex:
ARIA Integration
Svelte uses thearia-query package to validate ARIA usage, ensuring compliance with the WAI-ARIA specification.
Valid ARIA Roles
Warning:a11y_unknown_role
Only use valid ARIA roles:
No Abstract Roles
Warning:a11y_no_abstract_role
Don’t use abstract ARIA roles:
Best Practices
1
<button>, <nav>, <main> over generic <div> elementsTesting Accessibility
Browser DevTools
Modern browsers include accessibility inspectors:- Chrome/Edge: Accessibility pane in DevTools
- Firefox: Accessibility Inspector
- Safari: Accessibility Inspector in Web Inspector
Automated Testing
Use tools like axe-core or pa11y to catch issues:Additional Resources
- WebAIM - Web Accessibility in Mind
- WCAG Guidelines - Web Content Accessibility Guidelines
- A11y Project - Community-driven accessibility resources
- MDN Accessibility - Comprehensive accessibility documentation