LESSON 22
Responsive Design
Learning objective: Design pages that work on any screen size.
Understand
Responsive design adapts a layout to the device.
Start with a mobile-friendly base, use relative units, flexible images (max-width: 100%), and the viewport meta tag. The goal is one site that looks right on phones, tablets, and desktops.
Analogy: Responsive design is like water: it takes the shape of whatever container (screen) it is poured into.
See It in Action
Flexible images:
img {
max-width: 100%;
height: auto;
}How it works: Images never overflow their container and keep their proportions as the layout shrinks.
Try It Yourself
- Add the viewport meta tag if missing.
- Make images
max-width: 100%. - Resize the window and check for overflow.
Quick Quiz
What does max-width: 100% on images prevent?
Challenge
Make an existing page free of horizontal scrolling on a narrow screen.
Success condition: Your page has no horizontal overflow when the window is narrow.
+10 XP
Lesson Complete
You answered correctly and completed the required practice. Your progress has been saved on this device.
Continue to next lesson →