Responsive Web Design with CSS3 Media Queries: Viewport Meta Tag, Mobile First, Breakpoints, min-width and Testing in DevTools

HTML5 and CSS3 55 min min read Updated: Nov 17, 2026 Beginner
Responsive Web Design with CSS3 Media Queries: Viewport Meta Tag, Mobile First, Breakpoints, min-width and Testing in DevTools
Beginner Topic 1 of 3

What Is Responsive Design?

A responsive page adjusts its layout to the screen: one column on a phone, more columns on a laptop. You use one HTML file and CSS that adapts.

Step 1: The Viewport Meta Tag

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

Without it, phones pretend to be about 980px wide and shrink your page. This tag tells them to use their real width.

Step 2: Mobile First

Write styles for the small screen first, then add larger layouts with min-width media queries.

css .cols { display: grid; grid-template-columns: 1fr; gap: 1rem; } /* phones */ @media (min-width: 600px) { .cols { grid-template-columns: 1fr 1fr; } /* tablets */ } @media (min-width: 900px) { .cols { grid-template-columns: repeat(3, 1fr); } /* laptops */ }
Measured in Chrome

viewport 400px: 1 column viewport 700px: 2 columns viewport 1000px: 3 columns

Media Query Syntax

css @media (min-width: 600px) { ... } @media (max-width: 599px) { ... } @media (min-width: 600px) and (max-width: 899px) { ... } @media (orientation: landscape) { ... } @media (prefers-color-scheme: dark) { ... } @media (prefers-reduced-motion: reduce) { ... } @media print { ... }
FeatureChecks
min-width, max-widthViewport width
orientationPortrait or landscape
prefers-color-schemeLight or dark mode choice
prefers-reduced-motionUser wants less animation
hover: hoverDevice has real hover (mouse)
printWhen printing the page

Choosing Breakpoints

Do not chase device names. Open the page, make the window narrower and add a breakpoint where the layout breaks. Common starting points are around 600px, 900px and 1200px.

A Responsive Navigation

css .menu { display: none; } /* phones: hidden until a button opens it */ .menu.is-open { display: block; } .menu-btn { display: inline-block; } @media (min-width: 700px) { .menu { display: flex; gap: 1.5rem; } /* wide screens: show links */ .menu-btn { display: none; } }

Print Styles

css @media print { nav, footer, .ads { display: none; } body { color: #000; background: #fff; } a[href]::after { content: " (" attr(href) ")"; } }

Test in DevTools

  1. Press F12
  2. Click the device toolbar icon (a phone and tablet)
  3. Choose a device or drag the width
  4. Check there is no sideways scrolling
  5. Test portrait and landscape
  6. Test on a real phone when possible
No horizontal scrolling If the page scrolls sideways, look for fixed widths, big images or long words. Use max-width: 100% on images and overflow-wrap: anywhere for long text.

Practice

  1. Make a three column layout that becomes one column on phones
  2. Add a dark mode with prefers-color-scheme
  3. Hide navigation and ads when printing

Conclusion

Use the viewport meta tag, write mobile first CSS and add min-width queries where the design needs them.

Quick Summary: Responsive idea; viewport; mobile first; syntax; breakpoints; nav; print; testing.

Get Newsletter

Subscibe to our newsletter and we will notify you about the newest updates on Edugators