Most of your visitors are on phones — for many Vidaara learners, a phone is the only device. A responsive design is one that looks and works well at any width, from a 320px phone to a wide desktop. It's not a single feature but a mindset, and it pulls together much of what you've already learned.
1Mobile-first and media queries
The professional approach is mobile-first: write your base CSS for the small screen, then use media queries to add changes as the screen gets wider. A media query applies styles only when a condition is met:
/* base: mobile — one column */
.grid { display: grid; gap: 12px; }
/* tablet and up — two columns */
@media (min-width: 768px) {
.grid { grid-template-columns: 1fr 1fr; }
}
/* desktop — three columns */
@media (min-width: 1024px) {
.grid { grid-template-columns: repeat(3, 1fr); }
}Common breakpoints are around 480px, 768px and 1024px, but choose them based on where your design starts to look cramped, not by rote.
<meta name="viewport" content="width=device-width, initial-scale=1">. Forget it and the phone shows a shrunken desktop layout regardless of your media queries.- Mobile-first: write base styles for small screens, then add with
@media (min-width: …). - Common breakpoints ~480px / 768px / 1024px — but pick them where your design needs them.
- Responsive CSS only works with the
viewportmeta tag in place.
2Fluid layouts — stop using fixed pixels
Media queries handle big jumps, but a truly responsive layout is fluid between them. The trick is to avoid fixed widths and let things flex:
- Percentages and
max-width—width: 100%; max-width: 600px;fills small screens but caps on large ones. Far better than a rigidwidth: 600px. - Flexible images —
img { max-width: 100%; height: auto; }(from the Images lesson) so pictures shrink to fit. - Flexbox and Grid — already responsive-friendly; recall
repeat(auto-fit, minmax(200px, 1fr))reflows with no media query at all. clamp()— fluid sizing in one line:font-size: clamp(1rem, 4vw, 2rem)scales with the screen but never gets too small or too big.
- Prefer
width: 100%; max-width: …over fixed pixel widths. img { max-width: 100%; height: auto; }keeps images fluid; Flexbox/Grid adapt naturally.clamp(min, preferred, max)gives fluid sizing that never goes too small or large.- Test at 320px — no horizontal scrolling means it works almost everywhere.
★ Practical: a page that adapts
In any playground:
- Build a card grid that is one column by default and two columns at
min-width: 768pxvia a media query. - Constrain a content block with
width: 100%; max-width: 600px;. - Size a heading with
clamp()so it scales with the screen. - Narrow the preview to ~320px and confirm there's no sideways scrolling.
Ready to test yourself?
Take the short quiz. Score 60% or more to mark this lesson complete.
Start the quiz →💡 Log in to save your progress and earn the certificate.