0
0
HTMLmarkup~20 mins

Audio tag basics in HTML - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Audio Tag Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
rendering
intermediate
2:00remaining
What will this audio tag do in the browser?
Consider this HTML code:
<audio src="song.mp3" controls></audio>

What will the user see or experience when this code runs in a modern browser?
HTML
<audio src="song.mp3" controls></audio>
AAn audio player with play/pause buttons appears, allowing the user to play the song.
BThe audio plays automatically without any controls visible to the user.
CNothing appears on the page because the audio tag is empty.
DA download link for the song appears instead of a player.
Attempts:
2 left
💡 Hint
The controls attribute adds visible buttons for the user.
🧠 Conceptual
intermediate
2:00remaining
What does the 'autoplay' attribute do in an audio tag?
Given this audio tag:
<audio src="music.mp3" autoplay></audio>

What happens when the page loads?
HTML
<audio src="music.mp3" autoplay></audio>
AThe audio waits for the user to click play before starting.
BThe audio shows controls but does not play automatically.
CThe audio starts playing automatically as soon as the page loads.
DThe audio is muted and does not play at all.
Attempts:
2 left
💡 Hint
Autoplay means play without user action.
📝 Syntax
advanced
2:30remaining
Which audio tag syntax correctly includes multiple source formats?
You want to provide an audio file in both MP3 and OGG formats for better browser support. Which code snippet is correct?
A<audio controls src="sound.mp3" src="sound.ogg"></audio>
B<audio controls src="sound.mp3" type="audio/mpeg"><source src="sound.ogg" type="audio/ogg"></audio>
C<audio controls><source src="sound.mp3"><source src="sound.ogg"></audio>
D<audio controls><source src="sound.mp3" type="audio/mpeg"><source src="sound.ogg" type="audio/ogg"></audio>
Attempts:
2 left
💡 Hint
Use multiple tags inside the audio tag.
accessibility
advanced
2:00remaining
How to make an audio player accessible for screen readers?
Which attribute or technique improves accessibility for an audio player?
HTML
<audio controls src="podcast.mp3"></audio>
ARemove controls so screen readers do not get confused.
BAdd an aria-label describing the audio content, e.g., aria-label="Podcast episode 1".
CUse only autoplay without controls to avoid user interaction.
DAdd a title attribute with the file name only.
Attempts:
2 left
💡 Hint
Screen readers need descriptive labels.
layout
expert
3:00remaining
How to center an audio player horizontally and make it responsive?
You want the audio player to be centered on the page and adjust its width on small screens. Which CSS snippet achieves this best?
HTML
<audio controls src="music.mp3"></audio>
Aaudio { display: block; margin-inline: auto; width: 100%; max-width: 30rem; }
Baudio { text-align: center; width: 50%; }
Caudio { float: center; width: 300px; }
Daudio { display: inline; margin: 0 auto; max-width: 300px; }
Attempts:
2 left
💡 Hint
Use block display and auto margins for centering.