Responsive Design with Media Queries

Understanding Media Queries

Media queries let you apply different CSS styles based on the device's screen size or features, making your design responsive across desktops, tablets, and phones.

Example: A Box that Changes Based on Screen Size

Resize me!

Resize your browser or open this on different devices to see the box adjust size and font.

How It Works

The CSS below uses media queries for these breakpoints:

Quiz: Test Your Knowledge on Media Queries

1. What does the max-width media query do?

2. What screen sizes does @media only screen and (max-width: 768px) target?

3. How do you target a device with a minimum width of 1024px?