Sub topic 3
Choosing Visual, Auditory, and Haptic Feedback
This chapter assumes you know basic HTML, CSS, and JavaScript, and that you understand feedback as the system's response to a user action.
Choosing visual, auditory, and haptic feedback
Feedback reaches the user through three channels. Visual feedback changes what the screen shows, such as a label, a color, or a message. Auditory feedback is a sound. Haptic feedback is a vibration on devices that support it.
Use visual feedback as the default. It works for most users, and it can carry text. Add sound or vibration only as a supplement. Users may have muted their audio, and many browsers block sound until the user interacts with the page. Vibration is available only on some phones and is not a reliable channel.
Error messages and recovery
An error message should say what happened and how to fix it. "Could not save" alone leaves the user stuck. The following example shows a save button that reports progress, prevents duplicate clicks, and gives a recovery step on failure.
<button id="save" type="button">Save</button>
<p id="status" role="status"></p>
<script>
const button = document.getElementById("save");
const status = document.getElementById("status");
button.addEventListener("click", async () => {
button.disabled = true;
status.textContent = "Saving…";
try {
const response = await fetch("/api/save", { method: "POST" });
if (!response.ok) throw new Error("HTTP " + response.status);
status.textContent = "Saved.";
} catch (error) {
status.textContent = "Could not save. Check your connection, then select Save again.";
} finally {
button.disabled = false;
}
});
</script>Making cues and feedback accessible
Do not use color as the only cue. A red border alone fails users who cannot see red. Pair color with text or an icon. Text in the interface should meet a contrast ratio of at least 4.5:1 against its background, as set by WCAG AA. Keep focus outlines visible for keyboard users.
Putting it together: auditing a screen
Audit one screen in a fixed order. Check that each control has a visible signifier, that each action produces a response, and that each error explains the next step.
Exercise
A form field turns red when its input is invalid, and it shows no text. Name one fix that meets the accessibility guidance in this chapter.
Show answer
Add a text message beside the field that states the problem and the correction, and link it to the field with aria-describedby. The cue then no longer depends on color alone.