aria-expanded html attribute

ARIA attributes are related to accessibility. In this particular case, it's to let users with assistive technology (e.g. screen readers) know whether an element is expanded or not. It does not have any native effect on the styling of the element, but you can target that with CSS attribute selectors: [aria-expanded="true"]. You can toggle the value with JavaScript as needed.


The aria-expanded attribute is simply a flag for the user agent. It

Indicates whether the element, or another grouping element it controls, is currently expanded or collapsed.

...where that indication is for the element's contents, or if aria-controls is also specified, for the target element.

You set its value to indicate what you've done to the page (e.g., you've expanded or contracted a section). It doesn't have any particular behavior associated with it, it's for letting the user agent know what's going on so it can interpret that for its audience (who may be vision-impaired and need some other indication that a section is/isn't expanded).


As mentioned here:

WAI-ARIA is a spec defining support for accessible web apps. It defines bunch of markup extensions (mostly as attributes on HTML5 elements), which can be used by the web app developer to provide additional information about the semantics of the various elements to assistive technologies like screen readers.

WAI stands for: Web Accessibility Initiative

ARIA stands for: Accessible Rich Internet Applications

Hope it helps


Aria attributes in general are used to make web applications accessible to people with disabilities. They are used primarily by screen readers to determine how to treat html elements.

The aria-expanded attribute provides information about whether an element is in an expanded or collapsed state.

For example, if you have a collapsible element which contains a text, then a screen reader would know that the text is not currently displayed on the screen when the aria-expanded attribute is set to true.