ARIA: aria-hidden attribute
Description
- Purely decorative content, such as icons or images
- Duplicated content, such as repeated text
- Offscreen or collapsed content, such as menus
The presence of the aria-hidden attribute hides content from assistive technology but doesn't visually hide anything.
WARNING: Do not use
aria-hidden="true"on focusable elements.
Use caution when using aria-hidden to hide visibly rendered content from assistive technologies. You should not be hiding visible content unless doing so improves the experience for users of assistive technologies by removing redundant or extraneous content. Only when identical or equivalent meaning and functionality is exposed to assistive technologies can removing visible content from the accessibility API be considered.
NOTE: Consider all disabilities when hiding visibly rendered content from assistive technologies. Not all users of assistive technology are visually impaired. If visible content doesn't match text content in the accessibility API, the user experience will be negatively impacted for sighted users.
On the surface, the aria-hidden="true" and the role="presentation" and its synonym role="none" seem similar, but the intent behind each is different.
In all three scenarios, the attribute is unnecessary to add because the element has already been removed from the accessibility tree. Visually hiding elements with display or visibility hides content from the screen and from assistive technologies.
Example
<button>
<span class="fa fa-tweet" aria-hidden="true"></span>
<span class="label"> Tweet </span>
</button>
Values
false- : The element is exposed to the accessibility API as if it was rendered.
true- : The element is hidden from the accessibility API.
undefined(default)- : The element's hidden state is determined by the user agent based on whether it is rendered.
Associated interfaces
Associated roles
Used in ALL roles
Specifications
See also
aria-disabledaria-modalaria-expanded- HTML
hiddenattribute - CSS display property
- CSS visibility property
谢谢你的反馈!