Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does aria-hidden need a value? [duplicate]

Can I do <div aria-hidden> instead of <div aria-hidden="true"> or should I always do <div aria-hidden="true">?

like image 310
Lux Avatar asked Sep 19 '25 01:09

Lux


1 Answers

The current version of spec indicates that "aria-hidden" is a state, and it could have three 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.

This means that when aria-hidden attribute is set on an element without an explicit true or false value, it will be considered hidden if it is not rendered.

Can I do <div aria-hidden> instead of <div aria-hidden="true"> or should I always do <div aria-hidden="true">?

<div aria-hidden> and <div aria-hidden="true"> are not equivalent, and you must set aria-hidden="true" if the element is visible on screen but you wish to hide it from the accessibility API.

like image 136
Nisarg Shah Avatar answered Sep 21 '25 13:09

Nisarg Shah