Skip to content
Parwaz DigitalMarketing · Web · Courses

Web Development Course · Module 2, lesson 1

Mobile-first responsive design and media queries

Design for small screens first, then add layout for larger ones with the viewport meta tag and min-width media queries.

What you will learn

  • Add the viewport meta tag and explain why it is needed
  • Write min-width media queries that build up from a mobile layout
  • Test a page at different screen widths in developer tools

A responsive page adapts to the screen it is viewed on. The first step is the viewport meta tag in the head: <meta name="viewport" content="width=device-width, initial-scale=1">. Without it, phones pretend to be a wide desktop screen and shrink the page, so text becomes tiny. With it, the page width matches the device and your CSS can respond properly.

Mobile-first means writing your base styles for small screens, then adding media queries for wider ones. A rule inside @media (min-width: 768px) { ... } only applies when the screen is at least 768 pixels wide. For example, product cards can stack in a single column by default, then switch to a three-column grid inside the media query. Small screens get the simplest, lightest version.

Choose breakpoints where your content starts to look wrong, not around specific devices. Drag the browser window narrower and wider, and add a breakpoint when lines get too long or elements get cramped. Developer tools include a device mode that simulates phone and tablet sizes, but testing on a real phone is still worthwhile, as touch and scrolling feel different from a mouse.

Practice task

Rewrite your bakery page styles mobile-first: one column by default, two columns from 600px and three from 1000px. Check each width in device mode and on your own phone.

Web Development Course

Learn this properly,with a final project.

These pages summarise each lesson. The full course teaches them hands-on. Message us for the current fee, schedule, and format.

Available for new projects — Replies within one business day