Links, images and lists
Images and alt text
Goal: Embed images with meaningful alternative text · 8 min
<img src="photo.jpg" alt="Description" width="800" height="600">
- src: path of the image file.
- alt: text alternative read by screen readers and shown if the image fails. Describe the purpose: for a product photo "Red city bike with basket", for a logo link the destination ("Home"). Purely decorative images get empty alt (
alt="") so screen readers skip them. - width/height: let the browser reserve space and avoid layout jumps.
loading="lazy"delays off-screen images.
For images with a visible caption, wrap them in <figure> with <figcaption>.
Worked example: A figure with caption
- img with descriptive alt.
- figcaption provides the visible caption.
- figure groups both.
<figure>
<img src="lake.jpg" alt="Sunrise over a misty lake" width="800" height="533">
<figcaption>Lake Constance at dawn</figcaption>
</figure>