Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between aria-owns and aria-controls

Tags:

What is the real impact on an element when using

aria-owns="id" 

and(!)

aria-controls="id" 

How do the browsers notify the screen readers when these two attributes are used?

like image 524
EGN Avatar asked Nov 30 '15 16:11

EGN


People also ask

What is the use of aria owns?

The aria-owns attribute identifies an element (or elements) in order to define a visual, functional, or contextual relationship between a parent and its child elements when the DOM hierarchy cannot be used to represent the relationship.

What are aria-controls?

The aria-controls attribute identifies the element (or elements) whose contents or presence are controlled by the element on which the attribute is set, regardless of what type of interaction initiates the impacted behavior.

What are the three types of aria attributes?

The aria-label attribute defines a string value that labels an interactive element. The aria-labelledby attribute identifies the element (or elements) that labels the element it is applied to. The aria-level attribute defines the hierarchical level of an element within a structure.

What is difference between aria-label and aria-Labelledby?

The aria-label attribute gives an element its label; an element with the aria-labelledby attribute is labelled by something else.


Video Answer


2 Answers

Both aria-controls and aria-owns are used when the relation between the two element can't be determined from the DOM hierarchy itself.

aria-controls is intended to indicate that an element controls another one. E.g. control buttons for a video for instance, a toolbar for a visual editor or a button for a collapsible element. Screen readers like jaws will announce a shortcut to move the visual focus to the element. This requires the element to be in the visual flow (no display:none).

aria-owns indicate that an element depends on the current one when the relation can't be determined by the hierarchy structure.

To sum up, with an example, if you have a carousel with three parts:

  • on the left the clickable title list of each element in the carousel,
  • on the right the wrapper for the slides
  • on the bottom, the next and the previous buttons.

Result:

  1. aria-controls will be applied to buttons like "previous" or "next" to point to the wrapper.

  2. aria-owns will be applied to each element of the title list to point to each element inside the wrapper.

  3. the active element in the title list would have the aria-selected attribute

The intended effect is that you could move the visual focus of your screenreader to the determined element.

like image 180
Adam Avatar answered Sep 30 '22 15:09

Adam


The difference between -owns and -controls is that -owns creates a parent/child relationship where none exists, and -controls indicates that one thing controls the other. So A can control B, but A doesn't have to be a parent of B for that to be the case.

leonie watson

like image 24
Steve Faulkner Avatar answered Sep 30 '22 15:09

Steve Faulkner