HTML Multimedia

Beginner
⏱️ 12 min read
📚 Updated: Jul 2026
🎯 6 Examples + 6 Try It
audio / video / iframe

Introduction

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.

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.

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>

See also the audio tag reference for the full attribute list.

HTML5 Video

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>

See the video tag reference for more details.

Embedding External Multimedia

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.

Example (YouTube Embed)

html
<iframe width="560" height="315"
  src="https://www.youtube.com/embed/VIDEO_ID"
  title="Tutorial video"
  allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"
  allowfullscreen></iframe>

Replace VIDEO_ID with the ID from the YouTube URL. Always set a descriptive title so screen readers announce the embedded content.

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.

⚡ Quick Reference

Element / AttributePurpose
<audio>Embed sound
<video>Embed video
<source>Media file URL + MIME type
<track>Subtitles / captions (.vtt)
controlsShow native player UI
poster="url"Thumbnail before play
mutedStart without sound
<iframe>Embed YouTube / Vimeo

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>
Try It Yourself

How It Works

controls adds the browser’s player. source points to the MP3 file with the correct MIME type.

Example 2 — Audio with loop

html
<audio controls loop preload="metadata">
  <source src="t-rex-roar.mp3" type="audio/mpeg">
  Your browser does not support the audio element.
</audio>
Try It Yourself

How It Works

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>
Try It Yourself

How It Works

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>
Try It Yourself

How It Works

The poster image displays until the user presses play—useful for branding and layout stability.

Example 5 — YouTube Embed

html
<iframe width="560" height="315"
  src="https://www.youtube.com/embed/EngW7tLk6R8"
  title="HTML tutorial video"
  allowfullscreen></iframe>
Try It Yourself

How It Works

YouTube hosts the video; your page loads a sandboxed player via iframe. Swap the URL with any embed link from Share → Embed.

Example 6 — Complete Multimedia Page

Combines audio, video, and an embedded iframe on one page:

html
<!DOCTYPE html>
<html lang="en">
<head>
  <title>HTML Multimedia Example</title>
</head>
<body>
  <h1>HTML Multimedia Example</h1>

  <h2>Audio Example</h2>
  <audio controls>
    <source src="audio.mp3" type="audio/mpeg">
  </audio>

  <h2>Video Example</h2>
  <video width="640" height="360" controls>
    <source src="video.webm" type="video/webm">
  </video>

  <h2>Embedded Video</h2>
  <iframe src="https://www.youtube.com/embed/VIDEO_ID"
    title="Tutorial video" allowfullscreen></iframe>
</body>
</html>
Try It Yourself

How It Works

Each section uses a different embedding strategy: native audio, native video, and external iframe.

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

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 &amp; 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 Chrome All versions · Desktop & Mobile
Full support
Mozilla Firefox All versions · Desktop & Mobile
Full support
Apple Safari All versions · macOS & iOS
Full support
Microsoft Edge All versions · Chromium & Legacy
Full support
Internet Explorer IE 6+ · Legacy environments
Full support
Opera All modern versions
Full support
HTML5 audio & video elements Universal

Bottom line: Native media elements replaced Flash. Provide multiple formats for best coverage.

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.

Key Takeaways

📄 02

source

Inside tag.

Syntax
🎥 03

controls

User choice.

UX
🔗 04

iframe

YouTube.

Embed
05

track

Captions.

a11y

❓ Frequently Asked Questions

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.

Build a multimedia page in the editor

Add audio, video, and a YouTube embed, then preview everything live.

Open Try It editor →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

6 people found this page helpful