Responsive design means one set of HTML and CSS that rearranges itself to fit anything from a 360px phone to a 1920px monitor.
Most web traffic now arrives on phones, so a layout that only works at 1280px fails the majority of visitors.
The old answer was a separate mobile site at m.example.com, which meant building everything twice and watching the two copies drift apart.
The content stays identical across every width; only the arrangement, the sizes and the spacing change.
Responsive covers a laptop window dragged narrow and a tablet turned sideways, not just phones.
The Viewport Tag Is the Line Everything Depends On
Left alone, a phone pretends to be about 980px wide and then shrinks the whole page to fit, so your careful layout arrives tiny.
<meta name="viewport" content="width=device-width, initial-scale=1"> goes in the head and stops that.
width=device-width tells the CSS to treat a 390px phone as 390px wide rather than 980px.
initial-scale=1 opens the page at normal zoom instead of zoomed out.
Never add user-scalable=no, because it stops a person with low vision pinching to zoom in on your text.
Common Mistake
Without the viewport tag your media queries still run, but against the fake 980px width, so nothing fires when you expect.
A site can look perfectly responsive in a resized desktop browser and still fail on a real phone because of this one missing line.
Whenever a phone shows a shrunken desktop layout, check the head before touching any CSS.
Relative Units Let the Layout Breathe
A width in px is the same on every screen, while a width in % is measured against the parent, so it flexes as the parent does.
rem is a multiple of the root font size, normally 16px, so 1.5rem is 24px and it grows if the user raises their default text size.
em is a multiple of the element's own font size, which makes it right for padding inside a button that should grow with its label.
vw and vh are percentages of the viewport, so font-size: 5vw is 18px on a 360px phone and 64px on a 1280px screen.
Setting max-width: 65ch on body text stops a paragraph running to 200 characters a line on a wide monitor, which nobody can read comfortably.
Build the layout from percentages and fr units, and save px for hairline borders and small fixed details.
Images Have to Shrink Too
img { max-width: 100%; height: auto; } is the single rule that stops a 2000px photo bursting out of a 360px phone and forcing sideways scrolling.
max-width lets the picture shrink but never stretches it past its real size, where it would go soft and blocky.
height: auto keeps the aspect ratio, so faces stay the right shape as the width changes.
The srcset attribute offers the browser several sizes of the same photo, so a phone downloads the 600px file and a desktop takes the 1600px one.
object-fit: cover crops an image to fill a fixed box rather than squashing it, which is what a card thumbnail needs.
Tip
Test with the heaviest image on your site, not the smallest.
A CSS background image ignores max-width and needs background-size: cover instead.
Throttle the connection to Slow 3G in developer tools to feel what a 2MB banner really costs a visitor.
Media Queries Change the Rules at a Width
Definition
Media query
A CSS rule that applies a block of styles only when the screen matches a condition, most often a minimum or maximum width.
A media query wraps a block of CSS in a condition, and that condition is usually the width of the viewport.
@media (min-width: 600px) { } applies the rules inside only when the screen is at least 600px across.
The width at which you change the layout is called a breakpoint.
Pick breakpoints where your own content starts to look wrong, found by dragging the window slowly, rather than copying a list of phone model sizes that changes every year.
Two or three breakpoints handle almost any school project, and ten is a sign the layout is too fragile.
Media queries can test more than width, and @media (prefers-reduced-motion: reduce) lets you switch off animation for people who feel sick watching it.
Mobile First Means Writing the Small Layout First
Mobile first means your ordinary CSS, the part outside any media query, describes the narrow layout.
Each media query then adds what a wider screen makes possible, which is why they all use min-width.
The narrow version is normally one column, full width images and stacked navigation, so it is also the easiest thing to write.
Starting wide and stripping things away with max-width leaves an old phone downloading and working through every desktop rule it will never use.
It forces a real decision about what matters, because only so much fits above the fold on a 360px screen.
Deciding what that narrow layout should show first, and how the menu collapses, is a wireframing job covered in the interface design articles.
Example
Base CSS: .cards { display: grid; gap: 16px; } which gives a single column on a phone.
Then @media (min-width: 700px) { .cards { grid-template-columns: 1fr 1fr; } } for two columns on a tablet.
Then @media (min-width: 1100px) { .cards { grid-template-columns: repeat(3, 1fr); } } for three on a laptop.
Fingers Are Blunt: Touch Targets and Real Testing
A fingertip covers roughly 9mm of screen, so make anything tappable at least 44 by 44 CSS pixels.
Padding on a link grows the target without making the text bigger, which is usually the fix for a cramped menu.
Leave at least 8px of space between two targets so a thumb cannot hit both at once.
Touchscreens have no hover, so anything hidden behind :hover needs a tap version or it is invisible on a phone.
Test at 360px, 768px and 1280px as a minimum, using the device toolbar in developer tools.
Then test on a borrowed phone, because the simulator cannot show you the on screen keyboard covering half your form.
Screenshots at three widths, annotated with what you changed and why, make solid testing evidence for Criterion D.
Active recall
What exactly goes wrong on a phone when the viewport meta tag is missing?
What is the difference between rem and em, and when would you pick each?
Which two declarations make an image fluid, and what does each one do?
Why should a breakpoint come from your content rather than from a list of device widths?
Give two things you must change for touch that a mouse never needed.