Images and figures
Add useful images with meaningful alternative text and stable dimensions.
- Difficulty
- beginner
- Time
- 35 minutes
- Last verified
- 9/21/2026
What you will build
Add a project screenshot that remains understandable when the image cannot be seen.
Understand the idea first
src locates the file, alt carries the image's information, and dimensions reserve space. A caption connects it to the surrounding content.
Build it step by step
<figure>
<img
src="images/first-page.png"
alt="My HTML learning page showing progress and the first weekly note"
width="960"
height="540"
/>
<figcaption>The page after lesson four.</figcaption>
</figure>- Create
images, add your screenshot, and name itfirst-page.png. - Place the figure inside the learning article and verify it loads.
- Break the filename briefly to test whether the alt text carries the information.
- Enter the image's real pixel width and height.
Read the important lines
- Alt text describes the information the image provides here.
- Use
alt=""for a purely decorative image. figuregroups self-contained media with its caption.
Common mistakes and what to check
| Symptom | What to check |
|---|---|
| Using a C:\ absolute path | Keep assets in the project and use relative paths. |
| Using the filename as alt | Describe the useful visual information. |
| Changing one dimension carelessly | Keep the original aspect ratio and style size later with CSS. |
Extend the idea: audio, video, and embedded pages
After images, you will often meet media and embedded content. Learn the selection rules rather than memorizing every attribute:
<video controls width="640" poster="images/video-cover.jpg">
<source src="media/learning-demo.mp4" type="video/mp4" />
Your browser cannot play this video.
<a href="media/learning-demo.mp4">Download it instead</a>.
</video>- Give
audioandvideonativecontrols; do not autoplay sound. - Supply captions for video and a transcript for important audio.
- Use
iframeonly when an embedded page is necessary, and give it a usefultitle. svgsuits scalable graphics andcanvassuits script-driven drawing. Neither replaces real text and headings.
Practice without copying
Write alt text for a course certificate screenshot and for a decorative star beside a heading.
Check the answer after you try
Describe the name, course, and completion shown by the certificate; use empty alt for the star.
Completion check
- My page contains the required new content
- I can explain the key tags or attributes without the answer
- I deliberately created and fixed at least one error