The img Element src alt width height
Embed images correctly with all required attributes.
The img Element
The <img> element embeds an image in the page:
<img src="photo.jpg" alt="A golden retriever playing fetch">
<!-- img is a void element — no closing tag needed -->
<!-- src: path to the image file -->
<!-- alt: text description for screen readers and broken images -->The src Attribute
The src attribute specifies the image source:
<!-- Relative path -->
<img src="images/logo.png" alt="Company logo">
<!-- Root-relative path -->
<img src="/assets/banner.jpg" alt="Sale banner">
<!-- Absolute URL (external) -->
<img src="https://cdn.example.com/photo.jpg" alt="Mountain view">
<!-- Data URI (inline) -->
<img src="data:image/png;base64,iVBOR..." alt="Icon">All lessons in this course
- The img Element src alt width height
- Responsive Images with srcset and sizes
- The picture Element for Art Direction
- figure and figcaption