# Cheatsheet & Interview Q&A — Responsive & Mobile-First Design

Source: https://www.geekswithgeeks.com/en/responsive-design/cheatsheet-interview

> Quick reference: key terms, media query syntax, breakpoints, and answers to common interview questions.

## Responsive CSS quick reference

Essential patterns and syntax for responsive design.

```css
/* Viewport meta tag (in HTML head) */
<meta name="viewport" content="width=device-width, initial-scale=1.0">

/* Mobile-first base */
.container { width: 100%; padding: 16px; }

/* Media query - tablet and up */
@media (min-width: 768px) { .container { padding: 24px; } }

/* Flexible units */
body { font-size: 1rem; } /* Use rem */
.box { width: 100%; max-width: 1200px; } /* Use % */

/* Clamp for smooth scaling */
h1 { font-size: clamp(1.5rem, 5vw, 3rem); }

/* Images responsive */
img { max-width: 100%; height: auto; }

/* Grid auto-fit */
.grid { grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); }
```

## Interview Q&A

**Q: What is responsive design?** A: Design that adapts to any screen size using flexible layouts, media queries, and flexible media.

**Q: Why mobile-first?** A: Simpler CSS, forces prioritization of content, and mobile is 50%+ of traffic.

**Q: What's the difference between max-width and min-width media queries?** A: min-width is mobile-first (build up), max-width is desktop-first (break down).

**Q: How do you make images responsive?** A: Use max-width: 100%, srcset for resolution, and <picture> for art direction.

**Q: What's the minimum touch target size?** A: 44x44px (Apple) or 48x48px (Android).

## Viewport units cheatsheet

Quick reference for viewport and container-relative sizing.

```css
/* Viewport units */
1vw = 1% of viewport width
1vh = 1% of viewport height
1vmin = 1% of smaller dimension
1vmax = 1% of larger dimension

/* Usage */
h1 { font-size: clamp(1.5rem, 5vw, 3rem); }
.hero { height: 100vh; }
.sidebar { width: 25vw; }
```

## Interview tip: explain your approach

When asked about responsive design in an interview, explain the three pillars, your testing process, and real examples from your work.
