As a best practice, it is good to set the scrolling to "auto" or "yes" in the
An element that is normally focusable but is in an inactive state (e.g., a disabled input box or button) should be given a negative tabindex (tabindex="-1").
Should add the focus back to the element when active or needed (can use JS or TS).
Should avoid positive tabindex. Giving focus to non-interactive elements and disrupting the normal focus order may confuse and frustrate the users. Rarely do circumstances warrant adding a positive tabindex, such as tabindex=1 to a non-focusable element.
A skip link must be included to help users bypass the navigation menu.
Skip link should includes context about the link's purpose (e.g. "Skip to main content" ) and can use additional ARIA properties like aria-labelledby, aria-label.
Skip link can be visible or visually hidden (based on design) until a user tabs to it.
Should not override the default browser focus styling (e.g. "outline: 0" or "outline: none").
Custom focus styles are allowed.
Possible misuse | Correct use |
---|---|
Render large chunks of non-semantic HTML | Render smaller pieces of semantic HTML |
Not allowing time for dynamic content to be recognized by assistive technology | Using a setTimeout() time delay to allow users to hear the full message |
Applying style attributes for onFocus() dynamically | Use :focus for the related elements in your CSS stylesheet |
Applying inline styles may cause user stylesheets to not be read properly | Keep your styles in CSS files to keep the consistency of the theme |
Creating very large JavaScript files that slow down overall site performance | Use less JavaScript; prefer CSS for animations or sticky navigation for better performance |
Focus must also be maintained when a user navigates from page-to-page.
Anytime a user clicks on a link to go to another page within the application, the focus is either kept in the same place or potentially placed somewhere else entirely.
Here are the suggested focus placements when the user navigates from one page to another.
Place focus on the main container with an aria-live announcement.
Put the focus back on a link to skip to the main content.
Move the focus to the top-level heading of the new page.
Component state should be managed using ARIA attributes (e.g. use an aria-expanded attribute to tell the user whether a drop-down menu or list is expanded or collapsed.).
It's important to be selective when applying ARIA attributes. Think through the user flow to understand what critical information should be conveyed to the user.
If content is added or updated dynamically on the page (e.g., an alert message or text change), it should be announced to the user.
Better to use
(continue...)
The above is the detailed content of Accessibility (a) Rules - 2. For more information, please follow other related articles on the PHP Chinese website!