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

CSS CSS Layout Basics CSS Layout Project Adding Media Queries for Large Screens

gene c
gene c
13,630 Points

How and when do I determine whether to style the CSS using the normal method or using the media queries method?

The video styled the webpage up to a certain point and then used the media queries to style the rest of the webpage's layout. Even for full screen.

Lee Vaughn
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Lee Vaughn
Treehouse Teacher

You want to start with styles that are either consistent across all screen sizes (like background or text color) or geared towards small screen sizes. From there you add or change styles using media queries based on how the layout looks as you start to expand the screen. Media queries should be dictated by the look of the page, not specific screen sizes or break points.

2 Answers

Hello Eugene! Do yourself a favor and start building your website using the normal method. It will save you lots of time, and you will end up with a cleaner code. Many developers start building their website with the "Mobile First" approach in mind. They do it the normal way by writing their css, and then by gradually building their way up using media queries. So after you use have written your css., Make a new media query for mobile devices in the landscape view, then the tablet view, then the desktop view.
The following is a Bootstrap example of the media queries you could use for your css. I usually just do three: landscape, tablet, and desktop.

// Extra small devices (portrait phones, less than 576px)
// No media query since this is the default in Bootstrap

// Small devices (landscape phones, 576px and up)
@media (min-width: 576px) 
{ 
... 
}

// Medium devices (tablets, 768px and up)
@media (min-width: 768px) { ... }

// Large devices (desktops, 992px and up)
@media (min-width: 992px) { ... }

// Extra large devices (large desktops, 1200px and up)
@media (min-width: 1200px) { ... }

Those are the media queries set that Nick recommends:

  • 320px
  • 480px
  • 600px
  • 768px
  • 900px
  • 1200px

The 2014 Guide to Responsive Web Design

Beginner’s Guide to Responsive Web Design

gene c
gene c
13,630 Points

Hi Asaad, thank you for your answer.

So with your answer and with the mobile first approach, does that mean that i'll have to minimise my screen till its the size of a mobile phone screen and then style my webpage without media queries from there. And then start increasing my browser viewport and adding media queries?

Anytime! Yes. You have to build it minimized like its the size of a mobile phone screen and work your way from there. Here is an example on my Github page