HTML multimedia lets you add sound, video, and embedded content directly to web pages. Before HTML5, sites relied on plugins like Flash. Today, native <audio> and <video> elements work across modern browsers with built-in controls.
This tutorial covers syntax, common attributes, YouTube embeds, accessibility, best practices, and six hands-on examples you can run in the editor.
What You’ll Learn
01
audio
Play sound.
02
video
Show clips.
03
source
File formats.
04
iframe
Embed YouTube.
05
track
Subtitles.
06
a11y
Accessible.
Fundamentals
What Is HTML Multimedia?
HTML multimedia means using HTML elements to embed and control media—audio clips, video files, and content hosted on external platforms—without leaving the page.
The <audio> and <video> elements provide a standard API: play, pause, volume, and fullscreen (for video). The <source> child element lists file URLs and MIME types so browsers can pick a supported format.
💡
Beginner Tip
Place <source> and fallback text inside the opening and closing tags of audio or video—not after the closing tag. See the syntax sections below.
Audio
HTML5 Audio
The <audio> element embeds sound in a page. Common formats include MP3 (audio/mpeg), WAV (audio/wav), and Ogg (audio/ogg). Browsers differ slightly in format support, so offering two sources is a safe pattern.
Basic Syntax
html
<audio controls>
<source src="audiofile.mp3" type="audio/mpeg">
Your browser does not support the audio element.
</audio>
Attributes
controls — shows play, pause, and volume controls.
autoplay — starts playback when ready (often blocked unless muted).
loop — repeats the clip when it ends.
muted — starts with sound off; required for many autoplay cases.
preload — hints loading: none, metadata, or auto.
Example
html
<audio controls loop preload="metadata">
<source src="example.mp3" type="audio/mpeg">
Your browser does not support the audio element.
</audio>
The <video> element embeds moving pictures. Supported formats include MP4 (video/mp4), WebM (video/webm), and Ogg (video/ogg). Like audio, list multiple source elements for broader compatibility.
Basic Syntax
html
<video width="640" height="360" controls>
<source src="videofile.mp4" type="video/mp4">
Your browser does not support the video tag.
</video>
Attributes
controls — play, pause, volume, timeline, and fullscreen.
autoplay — auto-start (usually needs muted).
loop — replay when finished.
muted — no sound on start.
poster — image URL shown before playback begins.
width / height — player dimensions (use CSS max-width: 100% for responsive layouts).
Example
html
<video width="640" height="360" controls poster="thumbnail.jpg">
<source src="example.webm" type="video/webm">
<source src="example.mp4" type="video/mp4">
Your browser does not support the video tag.
</video>
When media is hosted on YouTube, Vimeo, or similar services, embed it with an <iframe>. The platform handles encoding, bandwidth, and playback. Copy the embed code from the service’s share dialog.
Replace VIDEO_ID with the ID from the YouTube URL. Always set a descriptive title so screen readers announce the embedded content.
Access
Accessibility Considerations
Multimedia must work for everyone, including users who rely on captions, transcripts, or keyboard navigation:
Provide captions or subtitles for spoken content using <track kind="subtitles">.
Offer a text transcript for audio-only material when possible.
Do not autoplay sound unexpectedly—respect user preferences and browser policies.
Ensure custom players expose keyboard controls and visible focus states.
Add meaningful title attributes on iframes.
Example of Subtitles
html
<video width="640" height="360" controls>
<source src="example.mp4" type="video/mp4">
<track src="subtitles_en.vtt" kind="subtitles" srclang="en" label="English">
Your browser does not support the video tag.
</video>
WebVTT (.vtt) files hold timed caption text. Learn more in the track tag reference.
Cheat Sheet
⚡ Quick Reference
Element / Attribute
Purpose
<audio>
Embed sound
<video>
Embed video
<source>
Media file URL + MIME type
<track>
Subtitles / captions (.vtt)
controls
Show native player UI
poster="url"
Thumbnail before play
muted
Start without sound
<iframe>
Embed YouTube / Vimeo
Hands-On
Examples Gallery
Six examples from basic audio to a full multimedia page. Each includes View Output and Try It Yourself.
Example 1 — Basic Audio
html
<audio controls>
<source src="t-rex-roar.mp3" type="audio/mpeg">
Your browser does not support the audio element.
</audio>
loop repeats playback. preload="metadata" loads duration and title without downloading the full file upfront.
Example 3 — Basic Video
html
<video width="640" height="360" controls>
<source src="flower.webm" type="video/webm">
<source src="flower.mp4" type="video/mp4">
Your browser does not support the video tag.
</video>
Two source elements cover WebM and MP4. The browser uses the first format it understands.
Example 4 — Video with Poster
html
<video width="640" height="360" controls poster="thumbnail.jpg">
<source src="flower.webm" type="video/webm">
Your browser does not support the video tag.
</video>
Each section uses a different embedding strategy: native audio, native video, and external iframe.
Pro Tips
Best Practices
✅ Do
Compress media files and offer modern formats (WebM, MP4)
Include controls so users choose when to play
Add captions with <track> for spoken video
Use poster and max-width: 100% for responsive video
Set title on every iframe embed
❌ Don’t
Autoplay loud audio without user consent
Put source outside the closing tag
Upload huge uncompressed video files
Rely on a single format every browser may reject
Forget mobile data costs for heavy media
Compatibility
Universal Browser Support
<audio> and <video> are supported in all modern browsers. Format support varies: MP4/H.264 and WebM cover most users. Always test on mobile Safari and Chrome.
✓ Baseline · Since HTML
HTML5 audio & video elements
<audio> and <video> are supported in all modern browsers. Format support varies: MP4/H.264 and WebM cover most users. Always test on mobile Safari and Chrome.
100%Core tag support
Google ChromeAll versions · Desktop & Mobile
Full support
Mozilla FirefoxAll versions · Desktop & Mobile
Full support
Apple SafariAll versions · macOS & iOS
Full support
Microsoft EdgeAll versions · Chromium & Legacy
Full support
Internet ExplorerIE 6+ · Legacy environments
Full support
OperaAll modern versions
Full support
HTML5 audio & video elementsUniversal
Bottom line: Native media elements replaced Flash. Provide multiple formats for best coverage.
Wrap Up
Conclusion
HTML multimedia gives you native tools to embed audio and video, plus iframes for hosted content. Use semantic elements, correct syntax, and accessibility features to build rich experiences that work across devices.
Next, draw graphics with the HTML Canvas tutorial, or explore tag references for audio and video.
HTML multimedia means embedding audio, video, and other media directly in web pages. HTML5 provides native audio and video elements so you no longer need Flash or other plugins.
The audio element plays sound only. The video element plays moving pictures with optional sound. Both support controls, loop, muted, and source children for file formats.
The source element lets you list multiple file formats. The browser picks the first format it supports. Always include fallback text between the opening and closing tags for old browsers.
Use an iframe with the embed URL from YouTube (Share → Embed). Add a title attribute for accessibility and allowfullscreen so users can expand the player.
Most browsers block autoplay with sound to protect users. Use muted autoplay if you need background video, or let users press play with controls.
Add a track element inside video with kind="subtitles", srclang, label, and a WebVTT (.vtt) file path. Users can turn captions on from the video controls.
Did you know?
The <video> element can also play audio-only files—but use <audio> for sound clips. It keeps markup semantic and avoids showing an empty video frame.