HTML Tutorial

Images & Media

Embedding photos, videos, and audio in HTML

Images (<img>)

The <img> tag is used to embed an image in a web page.
html
<img src="logo.png" alt="Company Logo" width="200">
Wait! The alt (Alternative Text) attribute is mandatory.
  1. It is read by screen readers for blind users.
  2. It is shown if the image fails to load.
  3. It helps search engines understand the image.

Video (<video>)

Modern HTML makes it very easy to host your own videos.
html
<video width="320" height="240" controls>
  <source src="movie.mp4" type="video/mp4">
  Your browser does not support the video tag.
</video>
Wait! The controls attribute adds the Play/Pause button and volume slider automatically.

Audio (<audio>)

Similar to video, the <audio> tag allows for music and sound clips.
html
<audio controls>
  <source src="song.mp3" type="audio/mpeg">
</audio>

Iframes (<iframe>)

An Iframe is used to display another web page (like a YouTube video or a Google Map) inside your current page.
html
<iframe src="https://www.youtube.com/embed/dQw4w9WgXcQ"></iframe>

Summary

TermDescription
srcThe path to the file
altDescriptive text for accessibility
controlsShow browser player controls
autoplayStart playing immediately (Use sparingly!)
mutedStart with no sound (Required for autoplay on many browsers)
Best ForBuilding rich, interactive, and visual websites
Logic"Multi-media embedding"
SafetyAlways use descriptive alt tags
ModernUse WebP or AVIF for much faster loading images
StandardUse <figure> and <figcaption> to group images with captions
IdentityMedia makes the web "The Web"