Example 1 — Get and Set ariaLabel (MDN)
Read the accessible name, then make it more specific.
const el = document.getElementById("close-button");
console.log(el.ariaLabel); // "Close"
el.ariaLabel = "Close dialog";
console.log(el.ariaLabel); // "Close dialog" How It Works
- Select the control that needs a clear accessible name.
- Read
ariaLabel. Starts as"Close"(MDN). - Assign a clearer string. Reflects to
aria-label. - Keep it short — name the action, do not write a sentence.

