Lesson 3 · Web Explorer
Adding media and interactive elements.
Most tags surround content. Images don't — there's nothing to put between an opening and closing tag, because the picture is the content.
So <img> is a self-closing tag. It stands alone and carries everything it needs as attributes:
<img src="photo.jpg" alt="Me at the beach">
src is where the picture lives — a filename or a web addressalt is a text description for when the image can't be seenIt's tempting to skip alt since nothing visibly breaks. Don't.
That text is read aloud to blind users by screen readers. It appears if the image fails to load. Search engines use it to understand your page.
Describe what the image shows, not that it's an image:
alt="My dog sleeping on a red sofa"alt="image" or alt="photo1.jpg"A page full of images with no alt text is, to someone using a screen reader, a page full of silence.
5 more parts in this lesson
Walkthroughs, code labs, mini-games and the checkpoint quiz unlock when you buy the course.