


Khusboo Tayal
Modern websites often include rich multimedia content such as audio and video to enhance user experience. HTML5 introduced built-in support for embedding audio and video files without relying on third-party plugins like Flash.
To embed audio, HTML uses the <audio> tag. This allows you to play sound files like .mp3, .wav, or .ogg.
Basic Syntax:
<audio controls> <source src="audiofile.mp3" type="audio/mpeg"> Your browser does not support the audio element. </audio>
| Format | MIME Type | Description |
|---|---|---|
| MP3 | audio/mpeg | Most widely supported |
| WAV | audio/wav | High-quality, large size |
| OGG | audio/ogg | Open-source, lightweight |
<audio controls> <source src="music.mp3" type="audio/mpeg"> Your browser does not support the audio element. </audio>
Output:
A media player will appear with Play, Pause, and Volume buttons.
To embed video content, use the <video> tag. Like audio, it supports native controls and multiple formats.
Basic Syntax:
<video width="480" height="270" controls> <source src="video.mp4" type="video/mp4"> Your browser does not support the video tag. </video>
Video File Formats:
| Format | MIME Type | Description |
|---|---|---|
| MP4 | video/mp4 | Best supported |
| WebM | video/webm | Open-source, lightweight |
| OGG | video/ogg | Alternative open format |
<video width="480" height="270" controls> <source src="sample.mp4" type="video/mp4"> Your browser does not support HTML5 video. </video>
Output:
A video player appears with play/pause, progress bar, volume, and fullscreen options.
You can include multiple <source> elements to provide fallback formats for browser compatibility.
<video controls> <source src="video.mp4" type="video/mp4"> <source src="video.webm" type="video/webm"> <source src="video.ogg" type="video/ogg"> Your browser does not support HTML5 video. </video>
<video width="480" height="270" autoplay loop muted poster="thumbnail.jpg"> <source src="promo.mp4" type="video/mp4"> </video>
| Tag | Purpose | Recommended? |
|---|---|---|
| <video> | Embed native video content | Yes |
| <audio> | Embed native audio content | Yes |
| <embed> | Legacy plugin-based multimedia (e.g., Flash) | Not recommended |
| <object> | Embed external resources (legacy) | Rare use cases |
Learn how to use AI to build, market and grow your business. Subscribe our newsletter to get AI tips, tools and prompts in your inbox to power your marketing, sales and business.
Tags- #htmlmultimedia #htmlvideo #htmlaudio #learnhtml #html5 #htmlmedia #webdevelopment #htmltutorial #embedmedia