Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / HTML

aria-controls — identify controlled elements

`aria-controls` connects a control with elements whose contents or visibility it manages.

Version: WAI-ARIA 1.2

Syntax

<button aria-controls="results count">Add result</button>

Its value is a space-separated list of element identifiers. Each identifier should resolve to the correct unique element in the document. Multiple targets are valid when one control actually manages them.

This is an assistive-technology relationship: it does not move elements, establish ownership, or install event handlers. It also does not change focus or visibility automatically. The intended function must work with an ordinary keyboard.

The example button controls a results list and its count. Its handler adds CSS and updates the count. The test checks both changed elements and two resolved relationships in the accessibility tree; it does not assume every screen reader offers a special shortcut to those targets.

Examples

<!doctype html><meta charset="utf-8">
<button id="add" aria-controls="results count">Add result</button>
<ul id="results"><li>HTML</li></ul><p id="count">1 result</p>
<output id="result"></output>
<script>
document.querySelector('#add').addEventListener('click', () => {
  const item = document.createElement('li'); item.textContent = 'CSS';
  document.querySelector('#results').append(item);
  document.querySelector('#count').textContent = document.querySelector('#results').children.length + ' results';
});
document.querySelector('#add').click();
document.querySelector('#result').textContent = 'items=' + document.querySelector('#results').children.length + '; count=' + document.querySelector('#count').textContent;
</script>

Result

items=2; count=2 results

Verified actual list and count changes together with resolved control relationships.

Sources