code
Accessibility in HTML and JavaScript
This chapter describes best practices for designing HTML/JavaScript applications that work well for all users, including those who rely on assistive technologies. We covered most common use cases in our components with built-in accessibility features.
For a detailed introduction to basic concepts and general techniques for designing accessible applications, see the accessibility section of the MDN Web Docs.
Accessibility attributes
Building accessible web experiences often involves setting ARIA attributes to provide semantic meaning where it might otherwise be missing. Use JavaScript to dynamically control the values of accessibility-related attributes.
When you work with ARIA attributes in JavaScript, use the setAttribute() method or direct property assignment:
// Use setAttribute for ARIA attributes
const button = document.querySelector('button');
button.setAttribute('aria-label', 'Save document');
// Or use direct property assignment
button.ariaLabel = 'Save document';
Static ARIA attributes can be set directly in HTML:
<!-- Static ARIA attributes require no extra syntax -->
<button aria-label="Save document"><i class="icon element-save"></i></button>
For iX components, use the dedicated ariaLabel attribute for elements contained inside components.
Example: Setting the aria-label for the icon buttons contained in ix-date-picker component.