HTML and CSS · lesson 19 of 30 · free

Responsive design and media queries — HTML and CSS for kids

People open web pages on phones, tablets and big screens, so a good page is responsive: it changes to fit. A media query wraps CSS that applies only when the screen matches. max-width means up to that width, so it is for narrow screens; min-width means at least that width, so it is for wide screens. The viewport meta tag helps phones show the page at the right size.

▶ Watch how it works

Got it? Practise ↓

Code tip

Does the screen match? — “a media query rule applies only when the screen width matches”

  1. @media (max-width: 600px) { … } applies when the screen is 600px or narrower.
  2. @media (min-width: 800px) { … } applies when the screen is 800px or wider.
  3. If the media query matches, its rule replaces the normal one; if not, the normal rule stays.

Use it for: Making pages that look good on a phone and on a laptop.

Worked example: 📱 The screen is 820px wide. What font-size (px) does the paragraph get?
p {
  font-size: 16px;
}
@media (min-width: 600px) {
  p {
    font-size: 22px;
  }
} → 22

  1. 820 is at least 600, so the min-width rule applies.
  2. The paragraph gets the @media size: 22px.

Check: On a 320px phone it would stay 16px ✓

▶ 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 19 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 📱 Responsive Ranger badge when you pass — and a certificate when you finish all 10 lessons of Part 2 · CSS. You can still take the test without signing in.

🖨️ CSS Worksheet: Media Queries

✨ 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.