
The ARIA specification lists eight relationship attributes. In the case of aria-labelledby, that relationship is "this element is labelled by that element". A relationship attribute creates a semantic relationship between elements on the page regardless of their DOM relationship. Relationships #Īria-labelledby is an example of a relationship attribute. So, for example, if an element has both an aria-labelledby and an aria-label, or an aria-labelledby and a native HTML label, the aria-labelledby label always takes precedence. Importantly, aria-labelledby overrides all other name sources for an element.



This is much like using a label element, with some key differences. aria-labelledby #Īria-labelledby allows us to specify the ID of another element in the DOM as an element's label. You might use an aria-label attribute when you have some kind of visual indication of an element's purpose, such as a button that uses a graphic instead of text, but still need to clarify that purpose for anyone who cannot access the visual indication, such as a button that uses only an image to indicate its purpose. This overrides any other native labeling mechanism, such as a label element - for example, if a button has both text content and an aria-label, only the aria-label value will be used. aria-label #Īria-label allows us to specify a string to be used as the accessible label. Let's look at the properties ARIA uses to create accessible labels.

In fact, ARIA is the only way to add accessible help or description text. ARIA provides several mechanisms for adding labels and descriptions to elements.
