HTML and CSS · lesson 7 of 30 · free

Images with img, src and alt — HTML and CSS for kids

The img tag puts a picture on a page. It is an empty tag, so all it needs goes in its attributes: src names the picture file, alt describes the picture in words, and width and height set its size in pixels. Alt text is shown if the picture cannot load, and screen readers read it aloud for people who cannot see the picture — so always write it.

▶ Watch how it works

Got it? Practise ↓

Code tip

File and words — “src names the picture; alt says what it shows”

  1. <img src="file.jpg" alt="what it shows" width="200"> — no closing tag.
  2. src = which file to load; alt = words describing it; width / height = size in pixels.
  3. If the picture fails, the browser shows the alt text; screen readers read it aloud.

Use it for: Adding photos and drawings to a page, and making pages that blind users can follow.

Worked example: 🖼️ The picture cannot load. Which text does the browser show instead?
<img src="moon.png" alt="The full moon" width="150"> → The full moon

  1. When a picture fails, the browser shows its alt text.
  2. alt="The full moon".

Check: moon.png is the file; “The full moon” is the description ✓

▶ Watch it animated

✏️ Practice

Work it out in your head or on paper, type the answer and press Check. Stuck? Press “Show me how”.

Right: 0 · Tried: 0

🏁 Lesson 7 test

20 questions. Check each answer, then go to the next one. Get 16 or more right to pass.

🏅 Sign in with Google to earn the 🖼️ Alt Text Hero badge when you pass — and a certificate when you finish all 10 lessons of Part 1 · HTML Basics. You can still take the test without signing in.

🖨️ HTML Worksheet: Images and Alt Text

✨ Free AI tutor

Ask the AI tutor about this lesson

Why does it work? When should you use it? Ask in English, मराठी or हिंदी.

Sign in with Google to ask Free — 20 questions a day.

👩‍🏫 HTML and CSS classes near you — online or at home

Prefer a real teacher? TalentJR teachers take live online classes anywhere in India and visit homes in selected cities. Tell us what you need and our team will call you with timings and fees.

Live online classesSmall groups or 1:1 with a teacher, from home, any city.
Teacher at homeA TalentJR teacher visits your home (selected cities).
At a centreClasses at a TalentJR partner centre near you, where available.
Badges, certificates & gifts A badge for every lesson you pass, a certificate for every part you finish, plus TalentJR Points for daily practice. Computer worksheets Flowcharts, block coding, spreadsheets and safe internet.