Quest 1 β’ Lesson 3
πΌοΈ Images & Multimedia
Images, videos, and audio make web pages engaging. The < img > tag is the simplest way to add an image.
"A picture is worth a thousand words β but the alt attribute tells screen readers what the picture shows."
image.html
<img src="photo.jpg" alt="A description of the photo" />
π§ Understanding the Image Tag
<img>β selfβclosing tag that embeds an image.srcβ the source (URL or file path) of the image.altβ alternative text (shown if image fails to load, read by screen readers). Always include alt for accessibility.width/heightβ optional attributes to set image dimensions.
π Image Sources: Local vs External
Local file β image stored in your project folder.
<img src="images/logo.png" alt="Logo">
External URL β image from another website.
<img src="https://placehold.co/300" alt="Placeholder">
π₯ Video & Audio (Bonus)
Video
<video controls width="400">
<source src="movie.mp4" type="video/mp4">
</video>
<source src="movie.mp4" type="video/mp4">
</video>
Audio
<audio controls>
<source src="song.mp3" type="audio/mpeg">
</audio>
<source src="song.mp3" type="audio/mpeg">
</audio>
β¨ Challenge: Add an Image to Your Page
Use an online placeholder image (e.g., https://placehold.co/300;) and add an appropriate alt attribute. Then try adding a local image (create a simple "myphoto.jpg" in the same folder).
<img src="https://placehold.co/300" alt="Placeholder image" width="300">
<img src="myphoto.jpg" alt="My own photo" width="300">
π Live Preview (Try It!)
Below is a real placeholder image rendered from the code above:
β€οΈ Support Free Education
This course is 100% free. If it helps you, consider buying me a coffee.
β Buy Me a Coffeeβ‘οΈ Ready for more?
Next lesson: Lists & Tables β organise data effectively.
Continue to Lesson 1.4 β(Coming soon β check back or buy Pro Pack for instant access)