HTML audio and video: embed media with controls, sources, and tracks
Answer: Use video and audio to embed media. Prefer audio for sound-only files, and include controls, sources, and tracks.
Elements and attributes
video can embed a sound file, but audio is the better element for sound-only media.
Both opening tags can take controls, autoplay, loop, mute, preload, and global attributes.
video also supports height, width, and poster.
Always include the boolean controls attribute. This makes the user controls visible. Users can control audio levels, mute the audio completely, and expand the video to fullscreen.
Sources, posters, and tracks
Include one or more source elements, each with a src attribute to a media file, if no src attribute is included on the opening video or audio tags.
The poster attribute names an image that can show while the video is downloading.
If the video plays and is subsequently paused, the poster is not re-shown.
track elements add timed text; kind may be subtitles, captions, descriptions, chapters, or metadata.
See also
Claims
- id: C1 claim: Prefer the audio element for sound files. source: S1 evidence: "the <audio> element is preferable for embedding sound files."
- id: C2 claim: Always include the controls attribute. source: S1 evidence: "Always include the boolean controls attribute."
- id: C3 claim: video also supports height, width, and poster. source: S2 evidence: "width
, andposter` attributes"
- id: C4 claim: The track kind attribute has five enumerated values. source: S2 evidence: "There are five enumerated values for the track
kindattribute"
Sources
- [S1] Audio and video. web.dev. https://web.dev/learn/html/audio-video . License: CC-BY-4.0. Accessed 2026-11-26.
- [S2] Audio and video (source). web.dev. https://raw.githubusercontent.com/GoogleChrome/web.dev/main/src/site/content/en/learn/html/audio-video/index.md . License: CC-BY-3.0. Accessed 2026-11-26.
License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted). Sources: web.dev, Audio and video; web.dev, Audio and video (source). CC-BY-4.0 (https://web.dev/learn/css/flexbox). Copyright Google LLC. web.dev text is CC BY 4.0. CC-BY-3.0 (https://raw.githubusercontent.com/GoogleChrome/web.dev/main/LICENSE). Copyright Google LLC. Except as otherwise noted, the content of this site is licensed under the Creative Commons Attribution 3.0 License. Text was condensed and changed from the originals.
License: CC-BY-4.0 · Summary by iinventedlight (AI-assisted). Sources: web.dev, Audio and video; web.dev, Audio and video (source). CC-BY-4.0 (https://web.dev/learn/css/flexbox). Copyright Google LLC. web.dev text is CC BY 4.0. CC-BY-3.0 (https://raw.githubusercontent.com/GoogleChrome/web.dev/main/LICENSE). Copyright Google LLC. Except as otherwise noted, the content of this site is licensed under the Creative Commons Attribution 3.0 License.
Cite this
iinventedlight. 2026. "HTML audio and video: embed media with controls, sources, and tracks." iinventedlight Library, iil:note:dffsar0f, version of 2026-11-26. https://iinventedlight.com/library/notes/html-audio-video/. License: CC-BY-4.0.
@misc{iil_note_dffsar0f,
author = {{iinventedlight}},
title = {{HTML audio and video: embed media with controls, sources, and tracks}},
howpublished = {iinventedlight Library},
year = {2026},
date = {2026-11-26},
url = {https://iinventedlight.com/library/notes/html-audio-video/},
note = {Permanent ID iil:note:dffsar0f. License: CC-BY-4.0.},
}
Spotted a mistake? Use the MCP feedback tool or email hello@iinventedlight.com. Or Report a correction (no account needed).
Extra files beside this note
These files use this note's license, shown below. Paper extras retain their reproduction status; a link is not a reproduction.
- html-audio-video.schema.json (schema; CC-BY-4.0)
- html-audio-video.table.json (table; CC-BY-4.0)
For language models and agents: start at /llms.txt | /agents.md | /.well-known/agent-library.json. This page in Markdown: /library/notes/html-audio-video.md.