Skip to main content
Brave Programmer Logo

BraveProgrammer

BraveProgrammer

HomeProjectsBlogsCoursesLessonsAbout

Site footer

BraveProgrammer

Free coding courses, practical tutorials, and real projects from BraveProgrammer. Learn web development with React, Next.js, and TypeScript.

Navigation

  • Home
  • Projects
  • Blogs
  • Courses

Resources

  • About
  • Lessons
  • Teach on BraveProgrammer

© 2026 BraveProgrammer. All rights reserved.

Responsive Design – Media Qu | CSS Basics to Advanced lesson | BraveProgrammer
  1. Courses
  2. /
  3. CSS Basics to Advanced

Lesson 23 of 50

·css

Responsive Design – Media Queries

10 mins

Course progress46%

What you'll learn

Keep these ideas in mind as you work through the lesson.

3 points
  • Use **mobile‑first** (`min-width`) strategy to keep the default stylesheet lightweight.
  • `prefers-color-scheme` and `prefers-reduced-motion` are user‑preference media features.
  • `@supports` helps you gracefully degrade when a property isn’t supported.

Media queries let you apply CSS conditionally based on the capabilities of the viewer’s device.

Basic Syntax

@media (min-width:768px) {
  /* styles for viewports 768 px and larger */
}

The rule inside only runs when the viewport width meets the condition.

Common Breakpoints (mobile‑first strategy)

DeviceBreakpoint
Phonesmax-width: 599px
Tabletsmin-width:600px and max-width:1199px
Desktopsmin-width:1200px

Why mobile‑first?

  1. Base stylesheet targets the smallest screens – less CSS to download for the majority of mobile users.
  2. Adding min-width queries adds styles as the screen grows, rather than overriding a huge mobile stylesheet.

Feature Queries – @supports

Detect whether a browser understands a given property before using it:

@supports (display:grid) {
  .container { display:grid; }
}

If the browser lacks Grid support, it falls back to the block outside the query.

Preference Media Features

  • prefers-color-scheme – Detect dark or light mode.
  • prefers-reduced-motion – Respect users who request less motion.
  • prefers-contrast – High‑contrast mode.

Example – Mobile‑First Nav

/* Base – hidden on mobile */
.nav { display:none; }
/* Show on tablets & larger */
@media (min-width:600px) {
  .nav { display:flex; gap:2rem; }
}

Pro Tip – Combine with CSS Custom Properties

Define a breakpoint variable once and reuse it:

:root { --bp-tablet: 600px; }
@media (min-width: var(--bp-tablet)) { … }

Now you only need to change the value in one place when your design evolves.

Make it stickPractice what you've learned1 quiz · 6 practical tests · Optional activities from CSS Basics to AdvancedBrowse activities
Previous lessonKeyframe AnimationsContinue to lesson 24CSS Custom Properties (Variables)Back to CSS Basics to Advanced curriculum