Skip to content
Learn Netverks

Lesson

Step 29/58 50% through track

responsive

Responsive HTML

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

This lesson

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

Traffic is predominantly mobile—layouts that only work on desktop fail users and metrics.

You will apply Responsive HTML in contexts like: Websites, hybrid apps, email templates, design systems, and CMS-driven content.

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 intermediate lessons feel comfortable and you are ready for production-style trade-offs.

Responsive design adapts layouts and assets across viewport sizes. HTML supplies hooks; CSS performs layout; media queries decide breakpoints.

Viewport meta element

<meta name="viewport" content="width=device-width, initial-scale=1">
  • Maps CSS pixels to device-independent pixels.
  • Omitting it forces legacy mobile browsers to emulate desktop widths.
  • Avoid disabling user zoom unless legally justified—accessibility suffers.

Responsive images

  • srcset/sizes hint intrinsic widths.
  • picture chooses art direction per breakpoint.
  • loading="lazy" conserves bandwidth below the fold.

Responsive typography

Use fluid CSS (clamp) rather than duplicating markup per breakpoint.

Touch targets

HTML cannot enforce sizes—CSS must ensure interactive elements meet minimum hit areas on phones.

Often neglected details

  • Dynamically injecting viewport tags after hydration can cause reflow jitter—SSR should emit final meta.
  • Forced colors / Windows high contrast—media queries complement semantic HTML separation; decorative-only breakpoints still need structure.

Example — srcset + sizes

<img
  src="/images/img_8124.webp"
  srcset="/images/car-with-man.jpg 640w, /images/img_8124.webp 1280w"
  sizes="(max-width: 600px) 100vw, 720px"
  width="1280"
  height="960"
  alt="Course sample photos: wide landscape (1280px WebP) versus smaller 16:9 JPG for narrow slots."
  loading="lazy"
>

Rendered — real files from /public/images (640w vs 1280w candidates)

Course sample photos: wide landscape (1280px WebP) versus smaller 16:9 JPG for narrow slots.

Open DevTools → Network and resize the window: the browser should favour the 640 px-wide asset on small viewports when sizes is honoured.

Mobile-first preview checks (expected candidate)

Use this quick matrix while resizing in DevTools. Focus on the request URL and transferred bytes in Network.

Viewport width sizes result Likely chosen candidate What to verify
360px ~360 CSS px /images/car-with-man.jpg (640w) Request should be the smaller file for narrow screens.
600px ~600 CSS px /images/car-with-man.jpg (640w) Still near breakpoint; large candidate usually unnecessary.
1200px ~720 CSS px (per sizes) /images/img_8124.webp (1280w) High-density displays may prefer bigger candidate for crispness.

If your browser keeps downloading the larger file at small widths, re-check sizes first—most real-world regressions start there.

Example — <picture>

<picture>
  <source media="(min-width: 900px)" srcset="/images/black-golden-retriever-with-a-blue-dummy.webp" type="image/webp">
  <img src="/images/car-with-man.jpg" width="640" height="360" alt="Car with a person next to it in a parking-style scene." loading="lazy">
</picture>

Rendered — wide viewports show the dog photo; smaller ones keep the 16:9 car frame

Car with a person next to it in a parking-style scene.

Important interview questions and answers

  1. Q: What is the practical difference between `id` and `class`?
    A: `id` must be unique and is used for fragments/labeling; `class` is reusable for styling and behavior grouping.
  2. Q: Why is `defer` commonly preferred for scripts?
    A: It preserves HTML parsing, executes after parse, and avoids blocking rendering unlike classic synchronous scripts.
  3. Q: How do `srcset` and `sizes` work together?
    A: `srcset` provides candidate files and `sizes` tells expected rendered width so the browser can pick an optimal resource.

Tip: Content order in HTML should make sense before CSS reorders visually.

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