The Image Element
Use <img> to embed images. It is a self-closing tag.
<img src="photo.jpg" alt="A sunset over the mountains">Important Attributes
| Attribute | Purpose |
|---|---|
src | Path or URL to the image file |
alt | Text description for screen readers and when image fails to load |
width / height | Reserve space to prevent layout shift |
loading="lazy" | Defer loading until image is near viewport |
<!-- Best practice -->
<img
src="photo.webp"
alt="Team photo at the office"
width="800"
height="400"
loading="lazy"
>Always write a meaningful alt text. Describe what is in the image, not "image of..." — screen readers already say "image".