← All notes

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

Sources

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

Permanent ID: iil:note:dffsar0f

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.},
}

Markdown

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.

All artifact files (JSON index)

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.