Prejsť na hlavný obsah
← 📄 HTML & the platform·Modul A4 · Lekcia 8
ÚlohaBuild an <audio> with controls and two sources: /track.mp3 (audio/mpeg) and /track.ogg (audio/ogg).

<audio>: rovnaký tvar, iný obsah

60 XP4 min
Teória

<audio> mirrors <video>

<audio controls preload="metadata">
  <source src="/podcast-ep-01.mp3" type="audio/mpeg" />
  <source src="/podcast-ep-01.ogg" type="audio/ogg" />
</audio>

All the same attributes that work on <video> work on <audio>: controls, preload, multiple <source> for format fallback, autoplay + muted.

Format support

  • MP3 — universally supported.
  • WebM/Opus — better quality at the same bitrate; supported on every modern browser except Safari (last I checked — verify).
  • AAC (m4a) — Apple's preference, widely supported.

For a podcast, MP3 is the safe default. WebM as a smaller backup.

Transcripts

For accessibility, audio content should always have a written transcript nearby:

<audio controls src="/podcast.mp3"></audio>
<details>
  <summary>Transcript</summary>
  <p>Anna: Welcome to the show…</p>
</details>

Audio doesn't support <track> for captions in the same way video does (the spec allows it but browser support is patchy). Inline transcript is the reliable answer.

🔒

Zaregistruj sa a začni programovať

Teória je otvorená pre každého. Editor, živý náhľad a kontrola sa odomknú so 7-dňovou bezplatnou skúškou — karta potrebná, zruš kedykoľvek.

Registrácia — bezplatná skúška →

Prvých 10 lekcií v každej trase je zdarma. Karta nie je potrebná.

← PredchádzajúcaĎalšia lekcia →

Jeden tip k Pythonu alebo webu denne — e-mailom

Krátke, ručne písané, žiadny spam. Odhlásiť jedným klikom.