Lesson 6 of 15
Images
The img Element
Images use the <img> tag — a self-closing tag (no closing </img>):
<img src="photo.jpg" alt="A beautiful photo">
Key attributes:
src— the image URL or file pathalt— alternative text (shown if image fails to load, required for accessibility)widthandheight— dimensions in pixels
<img src="https://picsum.photos/300/200" alt="Random photo" width="300" height="200">
Why alt text matters
Screen readers read the alt text aloud for visually impaired users. Search engines use it to understand images. Always include a meaningful alt attribute.
Your Task
Add an image with:
- A
srcpointing to any image URL - An
altdescription - A
widthattribute
HTML preview loading...
Loading...
Click "Run" to execute your code.