What are Media Queries?
Media queries are used to apply CSS styles based on device characteristics like screen size, width, height, and orientation.
Basic Syntax
CSSRead-only
1
Common Breakpoints
| Device | Width |
|---|---|
| Mobile | ≤ 768px |
| Tablet | 769px – 1024px |
| Desktop | ≥ 1025px |
Min vs Max Width
CSSRead-only
1
Mobile First Approach
CSSRead-only
1
Multiple Conditions
CSSRead-only
1
Orientation
CSSRead-only
1
Responsive Example
CSSRead-only
1
Best Practices
- Use mobile-first approach
- Use min-width for scalability
- Keep breakpoints consistent
- Test across multiple devices
Common Mistakes
- Too many breakpoints
- Using fixed layouts
- Not testing on real devices
- Overriding styles incorrectly
Conclusion
Media queries are essential for responsive design. They ensure your website looks good on all devices.