A select-all checkbox checks every visible task and updates a polite selected-count message.

Program

Select-all controls should name the list they affect and make the resulting selection count visible.

select_all_items.html
Visuals: captured from real browser rendering
<form id="tasks">
  <label><input id="select-all" type="checkbox" aria-controls="task-list"> Select all tasks</label>
  <ul id="task-list">
    <li><label><input class="task" type="checkbox"><span>Draft copy</span></label></li>
    <li><label><input class="task" type="checkbox"><span>Review links</span></label></li>
  </ul>
  <p id="selection-status" role="status">0 selected</p>
</form>
<style>
  .task:checked + span { font-weight: 700; color: #0f766e; }
</style>
<script>
  const selectAll = document.querySelector("#select-all");
  const tasks = document.querySelectorAll(".task");
  const selectionStatus = document.querySelector("#selection-status");
  selectAll.addEventListener("change", () => {
    tasks.forEach(task => task.checked = selectAll.checked);
    const selected = [...tasks].filter(task => task.checked).length;
    selectionStatus.textContent = `${selected} selected`;
  });
</script>
  1. Connect select-all to the task list.

    The bulk checkbox names the list it affects.
    The bulk checkbox names the list it affects.
  2. Show the selected count.

    The page starts with a visible count.
    The page starts with a visible count.
  3. Style selected task labels.

    Selected tasks get a clear visual cue.
    Selected tasks get a clear visual cue.
  4. Listen for the bulk change.

    Checking Select all starts the bulk update.
    Checking Select all starts the bulk update.
  5. Read the bulk checkbox state.

    The select-all checkbox becomes the source of truth.
    The select-all checkbox becomes the source of truth.
  6. Check every task item.

    Each item checkbox receives the same checked value.
    Each item checkbox receives the same checked value.
  7. Render the selected count.

    The status count now matches the selected items.
    The status count now matches the selected items.
aria-controls aria-controls points from the bulk control to the affected list.
checked checked stores each checkbox selection state.
status count A status count confirms the consequence of a bulk action.