HTML provides several tags to embed and control different types of media—such as images, audio, video, and external content—inside a webpage. These media elements make websites more interactive and visually appealing.
Used to display pictures or graphics.
<img src="image.jpg" alt="Description" width="300">
| Attribute | Description |
|---|---|
src |
File path (URL) of the image |
alt |
Text shown if the image fails to load |
width / height |
Resize the image |
loading="lazy" |
Loads image only when needed |
Used to embed sound clips, music, or voice recordings.
<audio controls>
<source src="audio.mp3" type="audio/mpeg">
Your browser does not support audio.
</audio>
| Attribute | Description |
|---|---|
| controls | Shows play/pause UI |
| autoplay | Plays automatically |
| loop | Repeats audio |
| muted | Starts muted |
| preload | How the audio file loads (auto, metadata, none) |
Used for embedding videos.
<video controls width="500">
<source src="movie.mp4" type="video/mp4">
Your browser does not support video.
</video>
Used to embed another webpage, video player (YouTube), or maps.
<iframe src="https://www.youtube.com/embed/xyz123" width="560" height="315"></iframe>
Used to group media with captions.
<figure>
<img src="mountain.jpg" alt="Mountain">
<figcaption>Beautiful mountain view</figcaption>
</figure>
Provides multiple media formats for compatibility.
<video controls>
<source src="video.mp4" type="video/mp4">
<source src="video.webm" type="video/webm">
</video>
Adds subtitles/captions to videos.
<video controls>
<source src="movie.mp4" type="video/mp4">
<track src="subtitles.vtt" kind="subtitles" srclang="en" label="English">
</video>
| Media Tag | Purpose |
|---|---|
| <img> | Embed images |
| <audio> | Embed audio clips |
| <video> | Embed videos |
| <source> | Supports multiple media formats |
| <track> | Add subtitles or captions |
| <iframe> | Embed external content (webpages, maps, videos) |
| <figure> | Group media content |
| <figcaption> | Caption for media (inside figure) |