Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial
Milan Milosevic
6,647 PointsNumber of Media Queries
Just a simple question, is too many media queries bad? And what should be some optimal number of them? In terms of slowing down a site loading or something? I'm having seven breakpoints (media queries) in my code, all of them are putting in just one simple change of one element's margin. Is that ok?
Thanks in advance
2 Answers
Eric Ellenbrook
9,006 PointsIn my opinion the number of media queries depends solely on the website that you have created. Some can get by with very few of them where some might need more media queries in order to make things look good.
Jonathan Grieve
Treehouse Moderator 91,254 PointsTreehouse has taught me that there's no one right or wrong answer to how many media queries you need.
My first strategy was to create as many media queries for the amount of device resolutions I wanted to target. Then I learned about fluid websites.
Basically you only need as many media queries as you have breakpoints. In responsive web design, a breakpoint is a point in your HTML/CSS in which elements overlap or don't look right. If a website doesn't look right at a certain viewport width, you should use a media query to try and put it right. :-)