Loading…
Images make your pages visual and engaging. The <img> element is self-closing — it has no closing tag because it does not wrap content.
<img src="photo.jpg" alt="A sunset over the ocean">
| Attribute | Purpose |
|---|---|
src | Source — the URL or path to the image file |
alt | Alternative text — a text description of the image |
Alt text is not optional. It serves three critical purposes:
<!-- ❌ Bad: too vague -->
<img src="dog.jpg" alt="image"><!-- ❌ Bad: just the filename -->
<img src="dog.jpg" alt="dog.jpg">
<!-- ✅ Good: descriptive -->
<img src="dog.jpg" alt="Golden retriever playing fetch in a park">
Below the heading, add an image with:
src="https://picsum.photos/300/200" (a free placeholder image service)alt="A random placeholder image"The preview should show a small photo beneath the heading.