Loading...
If audio on a web page plays automatically for more than 3 seconds, provide controls to pause or stop the audio, or control its volume.
<!-- Good Example: Audio with Controls -->
<audio controls preload="none">
<source src="podcast.mp3" type="audio/mpeg">
<source src="podcast.ogg" type="audio/ogg">
<p>Your browser doesn't support HTML5 audio.
<a href="podcast.mp3">Download the audio file</a>.</p>
</audio>
<!-- Good Example: Background Audio with User Control -->
<div class="audio-controls">
<button id="play-btn">Play Background Music</button>
<button id="pause-btn">Pause</button>
<button id="stop-btn">Stop</button>
<input type="range" id="volume" min="0" max="100" value="50">
<label for="volume">Volume</label>
</div>
<!-- Bad Example: Auto-playing Audio -->
<audio autoplay>
<source src="background-music.mp3" type="audio/mpeg">
</audio>Remember: Audio control is crucial for users with cognitive disabilities, hearing impairments, and those using screen readers.
Auto-playing audio can interfere with assistive technologies and cause disorientation.