# Responsive Web Design

> How one page fits a phone, a tablet and a wide screen. The viewport tag, media queries and breakpoints, and why phones come first.

**Course:** [HTML, CSS and JavaScript](https://learn.benibix.com/learn/development-web)  
**Time:** 12 min

**After this lesson you can:**

- Add the viewport tag to a page
- Write a media query for wider screens
- Plan a layout mobile first

## How one page fits every screen

Responsive web design means one page that changes its layout to fit the screen. It rests on two parts. A viewport tag tells a phone to use its real width. Media queries then change the CSS at set widths. Without the tag, a phone may draw the page 980 pixels wide and shrink it.

The viewport tag is one line in the <head>: a meta tag with width=device-width. Phones once drew every page as if on a desktop, then shrank it so the text was tiny. The tag tells the phone the page was made for small screens, so it uses the screen's own width.

A media query is a block of CSS that only applies when a test is true. @media (min-width: 768px) holds rules for screens at least 768 pixels wide. Inside it, a list in one column can turn into a grid of three. A hidden menu can open out into a full bar.

Each width where the layout changes is called a breakpoint. There is no official list. The best breakpoints come from the content: widen the window slowly, and add one where the layout starts to look wrong. Most sites need two or three, not ten.

Mobile first is the usual way to write it. The plain CSS is for the smallest screen, with one column and large tap targets. Then min-width media queries add columns and extras as the screen grows. It is easier to add to a simple layout than to strip a big one down.

Flexible units do half the work before any media query runs. Widths in % or fr stretch with the window. Text in rem follows the reader's own text size. Pictures with max-width: 100% never spill out of their box. A page built that way needs fewer breakpoints.

People often test only by dragging a desktop window narrower. That misses the real thing: thumbs, slow networks and a screen held upright. Open the page on a real phone, or at least use the phone view in browser DevTools, before calling it done.

```html
<meta name="viewport" content="width=device-width, initial-scale=1">

<style>
  .cards { display: grid; grid-template-columns: 1fr; gap: 1rem; }

  @media (min-width: 768px) {
    .cards { grid-template-columns: repeat(3, 1fr); }
  }
</style>
```
One column on a phone. At 768 pixels and wider, the same cards fall into three columns.

![On the left, a narrow phone shows three boxes stacked in one column. On the right, a wide screen shows the same three boxes side by side, under the rule @media (min-width: 768px).](https://learn.benibix.com/diagrams/dev-media-query.svg)

### Example: Jack's menu is tiny on phones

Jack's cafe menu looks fine on his laptop. On a phone, the text is so small that 7 in 10 visitors leave within a few seconds.

The page had no viewport tag. He adds the one line and a media query at 600 pixels, and the menu now shows as one readable column.

**Words in this lesson:** [Responsive Web Design](https://learn.benibix.com/term/design/responsive-web-design), [Viewport Meta Tag](https://learn.benibix.com/term/development/viewport-meta-tag), [Media Query](https://learn.benibix.com/term/development/media-query), [Responsive Breakpoint](https://learn.benibix.com/term/design/responsive-breakpoint), [Mobile-First Design](https://learn.benibix.com/term/design/mobile-first-design)

**Question:** What happens on a phone if a page has no viewport tag?

**Answer:** The phone may draw it wide, then shrink it so the text is tiny. Without the tag, a phone assumes a desktop page. It draws it on a wide virtual screen and shrinks it, so your media queries never see the real width.

---

Source: https://learn.benibix.com/learn/development-web/responsive-web-design
Author: Behnia Zarei (a developer in Vienna, Austria, who builds and teaches data, AI and business intelligence at BENIBIX)
Publisher: BENIBIX Learn (https://learn.benibix.com/)
Last updated: 2026-11-19
Licence: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Quote freely with attribution.
