Back to HTML

The HTML audio Element and Podcast Players

Coding Tutorials Team 6 July 2026

The audio element works almost identically to video, minus the visual dimension. Everything about sources, controls and autoplay behaves the same way, which makes it quick to learn if you already know one.

The basic form

<audio src="/media/episode-12.mp3" controls preload="metadata"> Your browser does not support the audio element. </audio>

The controls attribute is effectively mandatory. Without it the element renders as nothing at all, since there is no visual content, so an audio element with no controls and no script is invisible and unplayable.

Formats

MP3 plays everywhere and remains the safe default. AAC, usually in an MP4 container, offers better quality at the same bitrate and has broad support. Ogg Vorbis and Opus are open alternatives with good compression, and Opus in particular is excellent for speech at low bitrates.

<audio controls preload="metadata"> <source src="/media/episode-12.opus" type="audio/ogg; codecs=opus"> <source src="/media/episode-12.mp3" type="audio/mpeg"> </audio>

For a podcast, MP3 alone is usually the pragmatic choice, because the file will also be distributed through feeds and applications that expect it.

Bitrate for speech

Music and speech have very different requirements. Music typically needs a considerably higher bitrate to sound acceptable, while spoken word remains perfectly clear at much lower settings, particularly in mono.

Recording a podcast in stereo when both microphones capture the same room doubles the file size for no benefit. Mono at a modest bitrate produces files a fraction of the size, which matters when episodes run to an hour and listeners may be downloading over mobile data.

Preload and autoplay

Set preload to metadata so the player can display the duration without fetching the whole file. Loading a full hour of audio for every visitor who never presses play is a substantial and entirely avoidable cost.

Autoplay is subject to the same restrictions as video, which means it is blocked unless muted. Muted audio being pointless, autoplay is effectively unavailable, and that is the correct outcome. Sound starting unexpectedly is disruptive at best and genuinely alarming for someone using a screen reader, since it competes with the voice they are listening to.

Transcripts matter more than the player

The single most valuable addition to any audio content is a transcript, and it serves several audiences at once.

It makes the content available to anyone who is deaf or hard of hearing, for whom the audio alone is inaccessible. It serves people who would rather read than listen, who are typically a larger group than anyone expects. It allows the content to be searched, skimmed and quoted, none of which is possible with audio. And it gives search engines actual text to index, since the audio file itself is opaque to them.

Placing the transcript on the page rather than in a separate download is the better option for all of these. A collapsible section keeps it out of the way visually while leaving it present in the document.

Chapters and timestamps

For longer recordings, a list of timestamps linking to points in the audio helps enormously. This requires a small amount of JavaScript to set the playback position when a link is activated, and it turns an hour of undifferentiated audio into something navigable.

Where the transcript is on the page, linking each section heading to its timestamp gives readers both routes at once.

The track element works here too

Audio supports the track element, which is most useful for chapter markers. Captions are less relevant given the transcript, though a track can supply metadata that a custom player uses to display chapter titles during playback.

Feeds and hosting

A podcast reaches most of its audience through applications reading an RSS feed rather than through a player on your page. The feed references the audio files directly, which means your hosting has to serve them reliably and cope with a spike when an episode is released.

The player on your site is therefore a convenience for people who arrive from search rather than the primary distribution route. That is a reason to keep it simple, and a reason to make sure the page carries the episode notes and transcript, since those are what search engines can actually index.

Building a custom player

The default controls differ between browsers and cannot be styled consistently, which is why most branded players are custom built. The media element exposes a full scripting interface covering playback, position, volume and events, so building one is straightforward.

The part that is regularly done badly is keyboard support. Native controls are fully operable by keyboard and announce themselves properly. A custom player built from unlabelled divs usually is not, so any replacement needs real button elements, accessible names, and a slider that responds to arrow keys. If that work is not going to happen, the default controls are the better choice.