Provide User Control for Auto-Playing Audio
Why It Matters
Audio that starts playing automatically can interfere with screen reader audio output, making it difficult or impossible for blind users to navigate or understand the page. Unexpected audio can also be disruptive or startling for users, especially those with cognitive disabilities. Users must have control over auto-playing audio.
Fixing the Issue
Avoid automatically playing audio content. If audio must play automatically (e.g., background music, audio announcements), ensure it lasts less than 3 seconds or provide easily discoverable and operable controls to pause, stop, or adjust the volume of that specific audio source. Standard HTML5 <audio> or <video> elements with the controls attribute typically meet this requirement.
Good Code Example
Using the controls attribute provides user control:
-
<audio controls src="background_music.mp3"> Your browser does not support the audio element. <video controls muted src="promo_video.mp4"> Your browser does not support the video element. </video></audio>
Bad Code Example
Audio plays automatically on load without user controls:
-
<audio autoplay loop src="annoying_background_sound.mp3"> </audio>
