Skip to content
Learn Netverks

Lesson

Step 15/58 26% through track

images

Images

Last reviewed May 28, 2026 Content v20260528
Track mode
iframe_html
Means
HTML preview sandbox
Reading
~3 min
Level
beginner

This lesson

This lesson teaches Images—the ideas, syntax, and habits you need before moving on in HTML.

Without a solid grasp of Images, you will repeat mistakes in HTML exercises and on real pages or scripts.

You will apply Images in contexts like: Hero sections, articles, galleries, and social preview cards.

Read the lesson, edit HTML/CSS in the playground, press Run to preview, then answer the lesson MCQs. Also use the HTML reference desk when you need tag or attribute lookup.

When the previous lesson's MCQs feel easy and you can explain Images in your own words.

The <img> element embeds raster artwork or photographs. It is a void element—no closing tag—and requires thoughtful alt text.

Required semantics

  • src resolves to image bytes (relative or absolute URL).
  • alt communicates equivalent information for screen readers and appears when images fail to load.
  • width / height reserve intrinsic dimensions to reduce layout shift.
<img
  src="/images/baby-icon.webp"
  width="525"
  height="350"
  alt="Illustrated icon-style portrait of a baby wearing a bib"
>

Rendered output (/public/images/baby-icon.webp in this project)

Illustrated icon-style portrait of a baby wearing a bib

width/height match intrinsic pixels (525×350) so layout stays stable before CSS clamps the visual size.

Example — informative photograph

<img
  src="/images/black-golden-retriever-with-a-blue-dummy.webp"
  width="1773"
  height="1182"
  alt="Golden retriever holding a blue bumper toy while standing outdoors on grass."
  loading="lazy"
>

Rendered output

Golden retriever holding a blue bumper toy while standing outdoors on grass.

Decorative vs informative

  • Informative: describe succinctly what the image conveys (alt="Chart showing Q3 revenue up 12%").
  • Purely decorative: use alt="" so assistive tech skips ornamentation.
  • Functional images inside links/buttons: alt text should describe the action.

Responsive delivery

  • srcset + sizes pick resolutions for device pixels.
  • <picture> swaps formats (AVIF/WebP) or artistic crops.
  • loading="lazy" defers offscreen downloads.

Performance hygiene

  • Serve appropriately compressed formats (often WebP/AVIF with fallbacks).
  • Use CDN caching headers for immutable filenames.
  • Avoid scaling giant bitmaps purely via CSS width.

What developers underestimate

  • sizes / srcset correctness: wrong sizes forces browsers to download images far larger than rendered—profiles with DevTools networking + real devices.
  • CLS from missing dimensions: always pair width/height (or intrinsic aspect-ratio CSS) unless you knowingly accept shifting layout penalties.
  • Charts as bitmaps-only: complex graphs need summaries for screen readers; alt text has length limits mentally—combine with textual data tables nearby when needed.
  • Bypassing CSP on images? you still leak metadata / tracking pixels—privacy reviews include img sources.

Why lazy loading alone is insufficient

Browsers may still fetch prioritized above-the-fold images eagerly; prioritize LCP image with hints (fetchpriority) and avoid hero carousels that delay meaningful paint without user intent.

Important interview questions and answers

  1. Q: What makes image delivery accessible and performant?
    A: Meaningful `alt`, correct intrinsic `width`/`height`, and responsive sources (`srcset`/`sizes` or `picture`) based on viewport needs.
  2. Q: When do you use a table in HTML?
    A: Only for real tabular data, not page layout; use `th`, `scope`, and `caption` to preserve structure for assistive tech.
  3. Q: What is the role of the `head` element in production apps?
    A: It provides critical metadata like charset, viewport, title, canonical/social tags, and linked resources used by browsers and crawlers.

Challenge

Alt text drill

  1. Add an <img> with meaningful alt.
  2. Add a decorative image with alt="".

Done when: you can justify each alt choice in one sentence.

Interview tip Lesson completion confidence

Can you explain this lesson in 30 seconds without reading notes?

Not saved yet.

Playground

Runs in your browser in a sandboxed frame. Backend runners appear when this track’s profile allows them.

Check yourself

Multiple choice — immediate feedback.

Discussion

Past discussion is visible to everyone. Only logged-in users can post comments and replies.

Starter discussion topics

  • What confused you about this lesson?
  • How would you explain this to a teammate in 30 seconds?

Sign up or log in to post comments and sync lesson progress across devices.

No discussion yet. Be the first to ask a question.

Jump