CKTIS / HTML
role — an element’s accessibility role
The `role` attribute identifies an element’s semantic role for assistive technologies. It does not add appearance or behavior. Use it within ARIA in HTML rules, and prefer elements that already provide the appropriate native semantics.
Version: WHATWG HTML Living Standard; index snapshot date recorded separately
Syntax
role="role-name [fallback-role-name ...]"The role attribute communicates an element’s type, such as a group or button, to assistive technologies. It concerns semantics in the accessibility tree, not appearance. It does not replace an accessible name: in the example, group supplies the role and aria-label supplies the name Display options.
The value can contain whitespace-separated role names. The browser uses the first recognized non-abstract role name to resolve the role. The list supplies fallback roles, not several simultaneous roles. The role selected this way is not necessarily the role exposed in the accessibility tree. For example, on a focusable button, the browser must ignore none or presentation and expose the implicit button role instead. Abstract roles must not be used in page content.
Prefer a native HTML element with the appropriate semantics. button already has the button role, so repeating it is redundant. Permitted overrides depend on the element and ARIA in HTML rules; not every role is valid everywhere. Also satisfy the chosen role’s requirements for names, states, and structure.
Adding role="button" alone does not add keyboard handling, focusability, or actions. The example groups two native radio inputs (<input type="radio">) without overriding their roles. When the selected option changes, the script changes the sample text’s font size. The output is a console log of the declared role and aria-label values and the group’s visible text, not an inspection of the accessibility tree.
Examples
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Named group of display options</title>
</head>
<body>
<div id="display-options" role="group" aria-label="Display options">
<label><input type="radio" name="zoom" value="normal" checked> Normal size</label>
<label><input type="radio" name="zoom" value="large"> Large size</label>
</div>
<p id="sample">Sample text</p>
<script>
const group = document.getElementById('display-options');
const sample = document.getElementById('sample');
group.addEventListener('change', event => {
sample.style.fontSize = event.target.value === 'large' ? '1.5em' : '1em';
});
console.log('Declared role: ' + group.getAttribute('role'));
console.log('ARIA label: ' + group.getAttribute('aria-label'));
console.log('Visible group text: ' + group.innerText.trim().replace(/\s+/g, ' '));
</script>
</body>
</html>Result
Declared role: group ARIA label: Display options Visible group text: Normal size Large size
The displayed code and declared result were verified in an isolated environment using the method recorded in the verification evidence for this exact version.