CKTIS / HTML
aria-checked — a control’s checked state
`aria-checked` describes the checked state of a suitable control role; it does not implement checkbox behavior.
Version: WAI-ARIA 1.2
Syntax
<button role="checkbox" aria-checked="mixed">All topics</button>For a checkbox control use the strings true, false, or mixed. An absent state is undefined, not unchecked; a checkbox requires an explicit state. Mixed suits a partially chosen group; radio and switch roles do not support it. This is not an HTML boolean attribute enabled by presence.
Prefer a native checkbox first. A custom control needs keyboard operation, focus, a label, and appearance matching its state. Changing ARIA alone does not check associated inputs.
The example uses a native button with checkbox semantics to control a group. Initially one topic is checked; activation checks both and updates the state to true. The test verifies the actual inputs and accessibility-tree state, not a particular screen reader utterance.
Examples
<!doctype html><meta charset="utf-8">
<button id="all" role="checkbox" aria-checked="mixed">All topics</button>
<label><input class="topic" type="checkbox" checked> HTML</label>
<label><input class="topic" type="checkbox"> CSS</label>
<output id="result"></output>
<script>
const all = document.querySelector('#all');
const topics = [...document.querySelectorAll('.topic')];
function sync() {
const n = topics.filter(input => input.checked).length;
all.setAttribute('aria-checked', n === 0 ? 'false' : n === topics.length ? 'true' : 'mixed');
}
topics.forEach(input => input.addEventListener('change', sync));
all.addEventListener('click', () => {
const checked = all.getAttribute('aria-checked') !== 'true';
topics.forEach(input => { input.checked = checked; }); sync();
});
all.click();
document.querySelector('#result').textContent = 'selected=' + topics.filter(x => x.checked).length + '; checked=' + all.getAttribute('aria-checked');
</script>Result
selected=2; checked=true
The result shows two checked topics and true state. The click handler supplies behavior, not ARIA alone.