CKTIS / HTML
aria-label — a textual accessible name
`aria-label` gives an accessible name to an element whose role permits author-provided naming.
Version: WAI-ARIA 1.2
Syntax
<button aria-label="Close notice">×</button>Provide a brief localized action name, such as Close notice for a dismissal button. The attribute does not give arbitrary elements a role. Where visible text or a native label is possible, it is usually preferable.
The name can replace content text. Include the visible label so voice control matches the screen. Valid aria-labelledby takes precedence. This is neither a tooltip, operation instructions, nor an event handler.
The example icon button has the name Close notice while its decorative glyph is excluded from accessibility. A separate function hides the notice on activation. The test confirms its computed name and dismissal; translate the label together with the interface.
Examples
<!doctype html><meta charset="utf-8">
<p id="notice">Your settings were saved.</p>
<button id="close" aria-label="Close notice"><span aria-hidden="true">×</span></button>
<output id="result"></output>
<script>
document.querySelector('#close').addEventListener('click', () => { document.querySelector('#notice').hidden = true; });
document.querySelector('#close').click();
document.querySelector('#result').textContent = 'noticeHidden=' + document.querySelector('#notice').hidden;
</script>Result
noticeHidden=true
Verified the button’s name and action; ARIA alone does not dismiss the notice.