Media Queries for Standard Devices

Geoff Graham on

This page lists a ton of different devices and media queries that would specifically target that device. That’s probably not generally a great practice, but it is helpful to know what the dimensions for all these devices are in a CSS context.

Brought to you by DigitalOcean

DigitalOcean has the cloud computing services you need to support your growth at any stage. Get started with a free $200 credit!

If you think responsive’s simple, I feel bad for you son. We got 99 viewports, but the iPhone’s just one.
—Josh Brewer, March 10, 2010

A major component of responsive design is creating the right experience for the right device. With a gazillion different devices on the market, this can be a tall task. We’ve rounded up media queries that can be used to target designs for many standard and popular devices that is certainly worth a read.

If you’re looking for a comprehensive list of media queries, this repository is a good resource.

If you’re reaction to this is: you should never base your breakpoints on devices!! You have a good point. Justin Avery has a nice post on the possible pitfalls of using device-specific breakpoints. Choosing breakpoints based on your design and not specific devices is a smart way to go. But sometimes you just need a little help getting one particular situation under control.

Phones and handhelds

iPhone
/* ----------- iPhone 4 and 4S ----------- */

/* Portrait and Landscape */
@media only screen 
  and (min-device-width: 320px) 
  and (max-device-width: 480px)
  and (-webkit-min-device-pixel-ratio: 2) {

}

/* Portrait */
@media only screen 
  and (min-device-width: 320px) 
  and (max-device-width: 480px)
  and (-webkit-min-device-pixel-ratio: 2)
  and (orientation: portrait) {
}

/* Landscape */
@media only screen 
  and (min-device-width: 320px) 
  and (max-device-width: 480px)
  and (-webkit-min-device-pixel-ratio: 2)
  and (orientation: landscape) {

}

/* ----------- iPhone 5, 5S, 5C and 5SE ----------- */

/* Portrait and Landscape */
@media only screen 
  and (min-device-width: 320px) 
  and (max-device-width: 568px)
  and (-webkit-min-device-pixel-ratio: 2) {

}

/* Portrait */
@media only screen 
  and (min-device-width: 320px) 
  and (max-device-width: 568px)
  and (-webkit-min-device-pixel-ratio: 2)
  and (orientation: portrait) {
}

/* Landscape */
@media only screen 
  and (min-device-width: 320px) 
  and (max-device-width: 568px)
  and (-webkit-min-device-pixel-ratio: 2)
  and (orientation: landscape) {

}

/* ----------- iPhone 6, 6S, 7 and 8 ----------- */

/* Portrait and Landscape */
@media only screen 
  and (min-device-width: 375px) 
  and (max-device-width: 667px) 
  and (-webkit-min-device-pixel-ratio: 2) { 

}

/* Portrait */
@media only screen 
  and (min-device-width: 375px) 
  and (max-device-width: 667px) 
  and (-webkit-min-device-pixel-ratio: 2)
  and (orientation: portrait) { 

}

/* Landscape */
@media only screen 
  and (min-device-width: 375px) 
  and (max-device-width: 667px) 
  and (-webkit-min-device-pixel-ratio: 2)
  and (orientation: landscape) { 

}

/* ----------- iPhone 6+, 7+ and 8+ ----------- */

/* Portrait and Landscape */
@media only screen 
  and (min-device-width: 414px) 
  and (max-device-width: 736px) 
  and (-webkit-min-device-pixel-ratio: 3) { 

}

/* Portrait */
@media only screen 
  and (min-device-width: 414px) 
  and (max-device-width: 736px) 
  and (-webkit-min-device-pixel-ratio: 3)
  and (orientation: portrait) { 

}

/* Landscape */
@media only screen 
  and (min-device-width: 414px) 
  and (max-device-width: 736px) 
  and (-webkit-min-device-pixel-ratio: 3)
  and (orientation: landscape) { 

}

/* ----------- iPhone X ----------- */

/* Portrait and Landscape */
@media only screen 
  and (min-device-width: 375px) 
  and (max-device-width: 812px) 
  and (-webkit-min-device-pixel-ratio: 3) { 

}

/* Portrait */
@media only screen 
  and (min-device-width: 375px) 
  and (max-device-width: 812px) 
  and (-webkit-min-device-pixel-ratio: 3)
  and (orientation: portrait) { 

}

/* Landscape */
@media only screen 
  and (min-device-width: 375px) 
  and (max-device-width: 812px) 
  and (-webkit-min-device-pixel-ratio: 3)
  and (orientation: landscape) { 

}

Galaxy Phones
/* ----------- Galaxy S3 ----------- */

/* Portrait and Landscape */
@media screen 
  and (device-width: 360px) 
  and (device-height: 640px) 
  and (-webkit-device-pixel-ratio: 2) {

}

/* Portrait */
@media screen 
  and (device-width: 320px) 
  and (device-height: 640px) 
  and (-webkit-device-pixel-ratio: 2) 
  and (orientation: portrait) {

}

/* Landscape */
@media screen 
  and (device-width: 320px) 
  and (device-height: 640px) 
  and (-webkit-device-pixel-ratio: 2) 
  and (orientation: landscape) {

}

/* ----------- Galaxy S4, S5 and Note 3 ----------- */

/* Portrait and Landscape */
@media screen 
  and (device-width: 320px) 
  and (device-height: 640px) 
  and (-webkit-device-pixel-ratio: 3) {

}

/* Portrait */
@media screen 
  and (device-width: 320px) 
  and (device-height: 640px) 
  and (-webkit-device-pixel-ratio: 3) 
  and (orientation: portrait) {

}

/* Landscape */
@media screen 
  and (device-width: 320px) 
  and (device-height: 640px) 
  and (-webkit-device-pixel-ratio: 3) 
  and (orientation: landscape) {

}

/* ----------- Galaxy S6 ----------- */

/* Portrait and Landscape */
@media screen 
  and (device-width: 360px) 
  and (device-height: 640px) 
  and (-webkit-device-pixel-ratio: 4) {

}

/* Portrait */
@media screen 
  and (device-width: 360px) 
  and (device-height: 640px) 
  and (-webkit-device-pixel-ratio: 4) 
  and (orientation: portrait) {

}

/* Landscape */
@media screen 
  and (device-width: 360px) 
  and (device-height: 640px) 
  and (-webkit-device-pixel-ratio: 4) 
  and (orientation: landscape) {

}

HTC Phones
/* ----------- HTC One ----------- */

/* Portrait and Landscape */
@media screen 
  and (device-width: 360px) 
  and (device-height: 640px) 
  and (-webkit-device-pixel-ratio: 3) {

}

/* Portrait */
@media screen 
  and (device-width: 360px) 
  and (device-height: 640px) 
  and (-webkit-device-pixel-ratio: 3) 
  and (orientation: portrait) {

}

/* Landscape */
@media screen 
  and (device-width: 360px) 
  and (device-height: 640px) 
  and (-webkit-device-pixel-ratio: 3) 
  and (orientation: landscape) {

}

Google Pixel
/* ----------- Google Pixel ----------- */

/* Portrait and Landscape */
@media screen 
  and (device-width: 360px) 
  and (device-height: 640px) 
  and (-webkit-device-pixel-ratio: 3) {

}

/* Portrait */
@media screen 
  and (device-width: 360px) 
  and (device-height: 640px) 
  and (-webkit-device-pixel-ratio: 3) 
  and (orientation: portrait) {

}

/* Landscape */
@media screen 
  and (device-width: 360px) 
  and (device-height: 640px) 
  and (-webkit-device-pixel-ratio: 3) 
  and (orientation: landscape) {

}

/* ----------- Google Pixel XL ----------- */

/* Portrait and Landscape */
@media screen 
  and (device-width: 360px) 
  and (device-height: 640px) 
  and (-webkit-device-pixel-ratio: 4) {

}

/* Portrait */
@media screen 
  and (device-width: 360px) 
  and (device-height: 640px) 
  and (-webkit-device-pixel-ratio: 4) 
  and (orientation: portrait) {

}

/* Landscape */
@media screen 
  and (device-width: 360px) 
  and (device-height: 640px) 
  and (-webkit-device-pixel-ratio: 4) 
  and (orientation: landscape) {

}

Nexus Phones
/* ----------- Nexus 4 ----------- */

/* Portrait and Landscape */
@media screen 
  and (device-width: 384px) 
  and (device-height: 592px) 
  and (-webkit-device-pixel-ratio: 2) {

}

/* Portrait */
@media screen 
  and (device-width: 384px) 
  and (device-height: 592px) 
  and (-webkit-device-pixel-ratio: 2)
  and (orientation: portrait) {

}

/* Landscape */
@media screen 
  and (device-width: 384px) 
  and (device-height: 592px) 
  and (-webkit-device-pixel-ratio: 2)
  and (orientation: landscape) {

}

/* ----------- Nexus 5 ----------- */

/* Portrait and Landscape */
@media screen 
  and (device-width: 360px) 
  and (device-height: 592px) 
  and (-webkit-device-pixel-ratio: 3) {

}

/* Portrait */
@media screen 
  and (device-width: 360px) 
  and (device-height: 592px) 
  and (-webkit-device-pixel-ratio: 3)
  and (orientation: portrait) {

}

/* Landscape */
@media screen 
  and (device-width: 360px) 
  and (device-height: 592px) 
  and (-webkit-device-pixel-ratio: 3)
  and (orientation: landscape) {

}

/* ----------- Nexus 6 and 6P ----------- */

/* Portrait and Landscape */
@media screen 
  and (device-width: 360px) 
  and (device-height: 592px) 
  and (-webkit-device-pixel-ratio: 4) {

}

/* Portrait */
@media screen 
  and (device-width: 360px) 
  and (device-height: 592px) 
  and (-webkit-device-pixel-ratio: 4)
  and (orientation: portrait) {

}

/* Landscape */
@media screen 
  and (device-width: 360px) 
  and (device-height: 592px) 
  and (-webkit-device-pixel-ratio: 4)
  and (orientation: landscape) {

}

Windows Phone
/* ----------- Windows Phone ----------- */

/* Portrait and Landscape */
@media screen 
  and (device-width: 480px) 
  and (device-height: 800px) {

}

/* Portrait */
@media screen 
  and (device-width: 480px) 
  and (device-height: 800px)  
  and (orientation: portrait) {

}

/* Landscape */
@media screen 
  and (device-width: 480px) 
  and (device-height: 800px) 
  and (orientation: landscape) {

}

Laptops

Media Queries for laptops are a bit of a juggernaut. Instead of targeting specific devices, try specifying a general screen size range, then distinguishing between retina and non-retina screens.

/* ----------- Non-Retina Screens ----------- */
@media screen 
  and (min-device-width: 1200px) 
  and (max-device-width: 1600px) 
  and (-webkit-min-device-pixel-ratio: 1) { 
}

/* ----------- Retina Screens ----------- */
@media screen 
  and (min-device-width: 1200px) 
  and (max-device-width: 1600px) 
  and (-webkit-min-device-pixel-ratio: 2)
  and (min-resolution: 192dpi) { 
}

Tablets

iPad
/* ----------- iPad 1, 2, Mini and Air ----------- */

/* Portrait and Landscape */
@media only screen 
  and (min-device-width: 768px) 
  and (max-device-width: 1024px) 
  and (-webkit-min-device-pixel-ratio: 1) {

}

/* Portrait */
@media only screen 
  and (min-device-width: 768px) 
  and (max-device-width: 1024px) 
  and (orientation: portrait) 
  and (-webkit-min-device-pixel-ratio: 1) {

}

/* Landscape */
@media only screen 
  and (min-device-width: 768px) 
  and (max-device-width: 1024px) 
  and (orientation: landscape) 
  and (-webkit-min-device-pixel-ratio: 1) {

}

/* ----------- iPad 3, 4 and Pro 9.7" ----------- */

/* Portrait and Landscape */
@media only screen 
  and (min-device-width: 768px) 
  and (max-device-width: 1024px) 
  and (-webkit-min-device-pixel-ratio: 2) {

}

/* Portrait */
@media only screen 
  and (min-device-width: 768px) 
  and (max-device-width: 1024px) 
  and (orientation: portrait) 
  and (-webkit-min-device-pixel-ratio: 2) {

}

/* Landscape */
@media only screen 
  and (min-device-width: 768px) 
  and (max-device-width: 1024px) 
  and (orientation: landscape) 
  and (-webkit-min-device-pixel-ratio: 2) {

}

/* ----------- iPad Pro 10.5" ----------- */

/* Portrait and Landscape */
@media only screen 
  and (min-device-width: 834px) 
  and (max-device-width: 1112px)
  and (-webkit-min-device-pixel-ratio: 2) {

}

/* Portrait */
/* Declare the same value for min- and max-width to avoid colliding with desktops */
/* Source: https://medium.com/connect-the-dots/css-media-queries-for-ipad-pro-8cad10e17106*/
@media only screen 
  and (min-device-width: 834px) 
  and (max-device-width: 834px) 
  and (orientation: portrait) 
  and (-webkit-min-device-pixel-ratio: 2) {

}

/* Landscape */
/* Declare the same value for min- and max-width to avoid colliding with desktops */
/* Source: https://medium.com/connect-the-dots/css-media-queries-for-ipad-pro-8cad10e17106*/
@media only screen 
  and (min-device-width: 1112px) 
  and (max-device-width: 1112px) 
  and (orientation: landscape) 
  and (-webkit-min-device-pixel-ratio: 2) {

}

/* ----------- iPad Pro 12.9" ----------- */

/* Portrait and Landscape */
@media only screen 
  and (min-device-width: 1024px) 
  and (max-device-width: 1366px)
  and (-webkit-min-device-pixel-ratio: 2) {

}

/* Portrait */
/* Declare the same value for min- and max-width to avoid colliding with desktops */
/* Source: https://medium.com/connect-the-dots/css-media-queries-for-ipad-pro-8cad10e17106*/
@media only screen 
  and (min-device-width: 1024px) 
  and (max-device-width: 1024px) 
  and (orientation: portrait) 
  and (-webkit-min-device-pixel-ratio: 2) {

}

/* Landscape */
/* Declare the same value for min- and max-width to avoid colliding with desktops */
/* Source: https://medium.com/connect-the-dots/css-media-queries-for-ipad-pro-8cad10e17106*/
@media only screen 
  and (min-device-width: 1366px) 
  and (max-device-width: 1366px) 
  and (orientation: landscape) 
  and (-webkit-min-device-pixel-ratio: 2) {

}

Galaxy Tablets
/* ----------- Galaxy Tab 2 ----------- */

/* Portrait and Landscape */
@media 
  (min-device-width: 800px) 
  and (max-device-width: 1280px) {

}

/* Portrait */
@media 
  (max-device-width: 800px) 
  and (orientation: portrait) { 

}

/* Landscape */
@media 
  (max-device-width: 1280px) 
  and (orientation: landscape) { 

}

/* ----------- Galaxy Tab S ----------- */

/* Portrait and Landscape */
@media 
  (min-device-width: 800px) 
  and (max-device-width: 1280px)
  and (-webkit-min-device-pixel-ratio: 2) {

}

/* Portrait */
@media 
  (max-device-width: 800px) 
  and (orientation: portrait)
  and (-webkit-min-device-pixel-ratio: 2) { 

}

/* Landscape */
@media 
  (max-device-width: 1280px) 
  and (orientation: landscape)
  and (-webkit-min-device-pixel-ratio: 2) { 

}
Nexus Tablets
/* ----------- Nexus 7 ----------- */

/* Portrait and Landscape */
@media screen 
  and (device-width: 601px) 
  and (device-height: 906px) 
  and (-webkit-min-device-pixel-ratio: 1.331) 
  and (-webkit-max-device-pixel-ratio: 1.332) {

}

/* Portrait */
@media screen 
  and (device-width: 601px) 
  and (device-height: 906px) 
  and (-webkit-min-device-pixel-ratio: 1.331) 
  and (-webkit-max-device-pixel-ratio: 1.332) 
  and (orientation: portrait) {

}

/* Landscape */
@media screen 
  and (device-width: 601px) 
  and (device-height: 906px) 
  and (-webkit-min-device-pixel-ratio: 1.331) 
  and (-webkit-max-device-pixel-ratio: 1.332) 
  and (orientation: landscape) {

}

/* ----------- Nexus 9 ----------- */

/* Portrait and Landscape */
@media screen 
  and (device-width: 1536px) 
  and (device-height: 2048px) 
  and (-webkit-min-device-pixel-ratio: 1.331) 
  and (-webkit-max-device-pixel-ratio: 1.332) {

}

/* Portrait */
@media screen 
  and (device-width: 1536px) 
  and (device-height: 2048px) 
  and (-webkit-min-device-pixel-ratio: 1.331) 
  and (-webkit-max-device-pixel-ratio: 1.332) 
  and (orientation: portrait) {

}

/* Landscape */
@media screen 
  and (device-width: 1536px) 
  and (device-height: 2048px) 
  and (-webkit-min-device-pixel-ratio: 1.331) 
  and (-webkit-max-device-pixel-ratio: 1.332) 
  and (orientation: landscape) {

}
Kindle Fire
/* ----------- Kindle Fire HD 7" ----------- */

/* Portrait and Landscape */
@media only screen 
  and (min-device-width: 800px) 
  and (max-device-width: 1280px) 
  and (-webkit-min-device-pixel-ratio: 1.5) {

}

/* Portrait */
@media only screen 
  and (min-device-width: 800px) 
  and (max-device-width: 1280px) 
  and (-webkit-min-device-pixel-ratio: 1.5) 
  and (orientation: portrait) {
}

/* Landscape */
@media only screen 
  and (min-device-width: 800px) 
  and (max-device-width: 1280px) 
  and (-webkit-min-device-pixel-ratio: 1.5) 
  and (orientation: landscape) {

}

/* ----------- Kindle Fire HD 8.9" ----------- */

/* Portrait and Landscape */
@media only screen 
  and (min-device-width: 1200px) 
  and (max-device-width: 1600px) 
  and (-webkit-min-device-pixel-ratio: 1.5) {

}

/* Portrait */
@media only screen 
  and (min-device-width: 1200px) 
  and (max-device-width: 1600px) 
  and (-webkit-min-device-pixel-ratio: 1.5) 
  and (orientation: portrait) {
}

/* Landscape */
@media only screen 
  and (min-device-width: 1200px) 
  and (max-device-width: 1600px) 
  and (-webkit-min-device-pixel-ratio: 1.5) 
  and (orientation: landscape) {

}

Wearables

/* ----------- Moto 360 Watch ----------- */
@media 
  (max-device-width: 218px)
  and (max-device-height: 281px) { 

}

More on media queries

  • Gerard
    Permalink to comment#

    Let me share my @media queries. I’m using this scheme on my own WordPress theme and at the moment it’s working very well. What do you think of it?

    @media only screen
    and (max-width : 1024px) { }

    @media only screen
    and (min-width : 769px)
    and (max-width : 1024px) { }

    @media only screen
    and (max-width : 768px) { }

    @media only screen
    and (min-width : 481px)
    and (max-width : 768px) { }

    @media only screen
    and (max-width : 480px) { }

    @media only screen
    and (min-width : 321px)
    and (max-width : 480px) { }

    @media only screen
    and (max-width : 320px) { }

    It’s important to remember that max-width and min-width include the pixel referenced. For example, min-width: 768px includes the 768px position, the same occurs with max-width: 768px. It’s used twice and we have less control. On these cases, it’s better to add one pixel more to the min-width; for example, min-width: 769px.

    Scheme:
    = 769, <= 1024
    = 481, <= 768
    = 321, <= 480
    <= 320

  • Gunnar
    Permalink to comment#

    Hi,

    I’m wondering why so many different pixel-sets of different media-querys exists to somehow cover every potential screen resolution. What will happen if in maybe one year a complete different resolution will be required because of new hardware? Isn’t there a way to be more flexible and to work with proportions of a screen based on the actual font-size… e.g. with the attribute “em” ?

  • Michele
    Permalink to comment#

    I’m using @media only screen and (max-width: 768px) etc. in my css file, but I want images in my main html pages to show or not show depending on the screen size. How do I control that? Have you done that before? I just want to pop in a different image if screen size is smaller than the 1024px.

  • vir s
    Permalink to comment#

    hi guys,
    here you can use the following for devices:
    @media query only screen and (max-device-width: 480px){
    /*your styles for a 480px device*/
    }

  • Muhammad Kashif
    Permalink to comment#

    Hi

    my problem is that when i use @media (max-width: 320px) then page works fine . but below that . when i write code for @media (max-width: 800px) then 320 does not work just @media (max-width: 800px) works fine ,,,,in short both doesnot work at the same time
    anyone can answer ?
    will wait :)

  • Mar
    Permalink to comment#

    Hey Chris, thank you for your useful work!
    Will you upgrade this post in the near future?
    Bye

  • tozman
    Permalink to comment#

    Muhammad,

    Use the word and between the different conditions
    examples :
    @media (min-width: 321px) and (max-width: 800px) {}
    @media (max-width:320px) {}

  • Nitesh
    Permalink to comment#

    can you please tell the media query for Ipad mini. The media query for IPad is not working for IPad mini. Please help me for this

  • manoj kushwah
    Permalink to comment#

    You are right but my problem is a responsive media in overview for tablet and iPhone in use your media query not smartness.

  • adnan
    Permalink to comment#

    Hi,
    I am trying many media query but my website not convert in responsive style in Samsung Galaxy S3, on all devices site open in responsive style.

    any one can tell me right method and right media query for Samsung Galaxy S3.

  • Kevin Jackson
    Permalink to comment#

    How do responsive design code writers address phones that have more pixels wide than the old phones did. For instance, my cell phone (ZTE Warp Sync) has dimenions of 1280 x 720 pixels (not the tiny 340px Ive been seeing in tutorials and sample codes) with a pixel density of 293.72. 1280 (landscape) nor 720 (portrait) is considered phone size any of the media queries I’ve been seeing. Some of this code would render a site I make like a desktop, rather than a phone unless I’m missing something.

  • laminlay
    Permalink to comment#

    how to write responsive template step by step tutorial

  • laminlay
    Permalink to comment#

    hi

    my code not work @media (max-width:320px) {}

  • Michael
    Permalink to comment#

    Hello folks.
    I want to target a certain device using a specific browser.
    Now how do I accomplish that? do I nest the media queries?
    example:

    @media screen and (min width) and (max width) {
    @media (-webkit- etc) {
    }
    } 
    

    The device is nested in the screen parameters.

    Excuse the code, but you get my point.
    Or do I use

    @media screen and (-webkit-min-device-pixel-ratio:0) and (min-width : /px) and (max-width : /px)
    

    So far I have had no luck with both.

    Any help will be appreciated.
    Thanks,
    Michael

  • Antonio
    Permalink to comment#

    So, it’s seem to me that I’ve been the whole time setting the breakpoint false:

    @media(max-width:768px)
    @media(min-width:768px)

    I thought that was the propper way. I have had a lot of problems with devices 768px wide. Now I know why :|

  • Patrick
    Permalink to comment#

    Hi,
    i have a little question. I wrote this in my HTML-Code:

    This is only an example. My problem is that when i write an other alternative stylesheet with the same code like i wrote in this comment, the stylesheets don’t overwrite the others when I change the browser-width oder -height. Is this the mistake: …(min-width: 0px, max-width: 800px)” ?
    Must i write the code like this: …(min-width: 0px) and (max-width: 800px) ?
    Hope my english is good enough to understand me.
    I would be lucky about an answer.
    Thank you

  • surender sharma
    Permalink to comment#

    HI i am using (landscape and portrait) for screen size (1024×768). But again when i am using this method for screen size (736×414) then it’s not workign. Any Suggestion ? and also plz tell me that is this method can see in desktop browser?

  • cn arabia
    Permalink to comment#

    Hi! is this code works with mini iPad please
    /* iPads (portrait) ———– /
    @media only screen
    and (min-device-width : 768px)
    and (max-device-width : 1024px)
    and (orientation : portrait) {
    /
    Styles */
    }

    if not please i need it thank you .

  • Shahbaz Akhtar
    Permalink to comment#

    Thank a lot is working fine.

  • David Englund
    Permalink to comment#

    I am using the Responsive Theme. What if I want to hide my sub-menu items on the desktop, but show them on the mobile? I use the “Responsive Menu” plugin for mobile, which provides a nice slider expand/collapse look for menus there. But, on the desktop I don’t want sub-menus to show. The main menu items (e.g., About) will take you to that section/page of the website, where a sidebar navigation will then be used from that point on for all the associated pages.

  • zan
    Permalink to comment#

    Thanks for this. Really helpful. :)

  • tamtam
    Permalink to comment#

    And why there is no Windows phone devices ?

  • JT
    Permalink to comment#

    Chris is a superstar of a CSS pro, but also a very nice dude. I emailed him a couple of times and he always responded to me. I give you and Paul Irish a lot of props.

    In the previous version of this article, Chris put everything in one big section. It was very helpful. I did the same thing below…

    http://codepen.io/anon/pen/LEoRNz.css

  • Natalie
    Permalink to comment#

    Thanks for the updated queries, they work great.

  • Najeh
    Permalink to comment#

    And why there is no Windows phone devices ?

  • Brian

    Hi,

    I have a general question regarding media queries.

    Is it possible to target individual screen sizes instead of using min-width and max-width etc…

    I would like to start on the laptop sizes:

    1024 x 768

    up to

    1920 x 1080

    Then eventually work into mobile devices, but I found it particularly difficult to target that way. I have tried lots of ways but it just seems that if I use min-width, max-width for example, I usually end up changing the styles for several resolutions with only one media query. Any solutions to this? I know a lot of you go through this (when starting out), but what have you done to resolve this issue? Any tips and/or suggestions?

    Thank you
    Brian

  • Carlie

    Hello.

    I have two div containers for food menu items. One is called menu-container and is a class the other is mobile-menu and is an id. I want to show just .menu-container on the desktop and just #mobile-menu on phone and tablet. I have the max-width set to 1047 and the min-width 1048. When I view it mobile everything looks and works great but when I view it on the desktop both menus show.

    This has been driving me crazy and I am not sure how to resolve this issue.

    Thanks,
    Carlie

  • Greggman

    These media queries don’t seem to work on iOS 8.3 (haven’t tested older OSes). Unless I’m missing something. For example here’s a simple test. For iPhone4/4s the background should be red. For anything larger it should be blue.

    But it ends up being red for iPhone5/5s, iPhone6, iPhone6Plus. It’s blue for iPadAir, iPad Retina, Desktop.

    How do I get it work for iPhone4/4S only? (basically shorter screens)

    <!DOCTYPE html>
    <html>
    <head>
      <meta name="apple-mobile-web-app-capable" content="yes">
      <meta name="apple-mobile-web-app-status-bar-style" content="black">
    
      <meta name="HandheldFriendly" content="True">
      <meta name="MobileOptimized" content="320">
      <meta name="viewport" content="width=device-width, target-densitydpi=160dpi, initial-scale=1.0, maximum-scale=1, user-scalable=no, minimal-ui">
      <meta name="format-detection" content="telephone=no" />
    <style>
    body { background-color: blue; }
    
    /* ----------- iPhone 4 and 4S ----------- */
    
    /* Portrait and Landscape */
    @media only screen
      and (min-device-width: 320px)
      and (max-device-width: 480px)
      and (-webkit-min-device-pixel-ratio: 2) {
      body { background-color: red; }
    }
    </style>
    </head>
    <body>
    Testing
    </body>
    </html>
    
  • wady

    I wrote the 4 standard media queries with bootstrap.It is ok.
    But it is not ok in pixels between the media queries because I used padding or margin.
    How I can solve this problem and are many other media queries?

  • mukesh
    Permalink to comment#

    hi i wants to now media query for the landscape and Portrait width and height

  • hiremwfor.com
    Permalink to comment#

    This is really good!!

  • Luke
    Permalink to comment#

    Thanks for the write up. This is a great resource!

    Is it possible to target a particular screen width AND HEIGHT? For instance, we’ve developed a touch screen kiosk/web app that’s nothing more than a responsive website tailored to a specific touchscreen monitor width and the usual mobile sizes. The issue comes in the “bleed-over” of target sizes via min- and max-widths causing a layout fix on the touchscreen to break the layout on mobile devices. If there’s a way to target a specific width WITH a specific height, that might fix our issue.

    Any help would be greatly appreciated!

  • Nate
    Permalink to comment#

    It seems like the best idea is to choose the widest portrait of the cell phones and simply make ALL portrait-size mobile device design start at that size. Rather than collapsing columns and stuff at 480px, you’ll do it at 736px width instead because of of the iPhone 6.

    That’s the simplest.

    But, isn’t there something much simpler that Zurb Foundation is doing? And what about device-aspect-ratio instead of pixels?

  • Ken Swarthout
    Permalink to comment#

    Man, I’m having trouble with this media query stuff. I followed a tutorial on how to build a navigation bar. I built my navigation bar off the tutorial. It’s a bit different. I just took the basic idea from the tutorial. Anyway, this is my problem, when the screen is smaller, the nav bar changes. You can click the nav bar. It opens up a vertical navigation bar (I call this a mini-menu). While the mini-menu is open, if you resize the browser and make it larger than 840 pixels, the old navigation bar is misplaced. You can see what I’m talking about at my site. http://JetBBS.com/js/click.js) but I’m not sure what. jQuery isn’t my strong suit. Thanks!

  • Aeakanshi Agarwal

    I want to known the difference between media query and breakpoints,is there is any difference between both of them,
    if yes then please Reply…
    thank you.

  • Al
    Permalink to comment#

    Any particular reason why screen is the target and not all as in

    @media all and (min-width: 768px) {}

  • Håkan Olsson
    Permalink to comment#

    Sorry but can someone explain how and when this article is helpful.

    Example:

    The query in the iPhone 4 and 4S section (copy/pasted below) is going to effect a lot more devices than iPhone 4 and 4S.

    /* ———– iPhone 4 and 4S ———– /
    /
    Portrait and Landscape */
    @media only screen
    and (min-device-width: 320px)
    and (max-device-width: 480px)
    and (-webkit-min-device-pixel-ratio: 2) {}

    It’s going to effect for example:
    iPhone 5
    iPod Touch
    LG Optimus G
    Samsung Galaxy Note
    Samsung Galaxy Note 2
    Samsung Galaxy S5
    Samsung Galaxy S3
    Samsung Galaxy Nexus
    LG Nexus 4
    Microsoft Lumia 830
    Sony Xperia S
    ..and many many more devices. So what’s the use of spec this as “iPhone 4 and 4S”?

    Another thing. In the query — how do the (max-device-width: 480px) relate to iPhone 4 and 4S though the device-width for these two devices is 320px?

  • Håkan Olsson
    Permalink to comment#

    For iphone 4 and 4s, device-width would probably be 480px in landscape mode — but only if these two devices were Android phones.

    Device-width works differently on IOS and Android. For Android it’s (usually/not allways) two (2) device-width. One for the short side in portrait orientation and the other for the long side in landscape mode.

    However, in IOS there is only one (1) device-width. It’s the shorter side, no matter what orientation. So actually, for the iphone 4 and 4s the device-width is 320px — even in landscape orientation.

    Another problem is that different browsers respond differently to device-width. Example: The Android default browser and Dolphin (but not Chrome, Opera, Firefox) use physical values not CSS pixels which is the norm.

    All this together means that using device-width for the page layout is not very far from using random numbers :|

  • Wasim Khan
    Permalink to comment#

    Cool Stuff,

    What about the bigger screens, that exceeds 1244px like 1824px….

    Can we use

    @media screen
    and (min-device-width: 1800px)
    and (max-device-width: 2200px)
    and (-webkit-min-device-pixel-ratio: 1) {
    }

  • Frank @tekshrek
    Permalink to comment#

    Grandios! :-D

    I’m very happy. Thank you.

  • sbrewitt
    Permalink to comment#

    I’m not a developer at all but trying – thank you to everyone who’s posted here. It’s helped me. Can anyone tell me what I have two ads returned in this code? Or how I need to correct it? Very grateful.

    .adslot_1 { width: 300px; height: 250px; }
    @media (min-width:300px) { .adslot_1 { width: 320px; height: 50px; } }
    @media (min-width:500px) { .adslot_1 { width: 320px; height: 50px; } }
    @media (min-width:600px) { .adslot_1 { width: 320px; height: 50px; } }
    @media (min-width:800px) { .adslot_1 { width: 320px; height: 50px; } }
    @media (min-width:900px) { .adslot_1 { width: 300px; height: 250px; } }
    @media (min-width:1024px) { .adslot_1 { width: 300px; height: 250px; } }

    <script async src=”http://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js””>
    (adsbygoogle = window.adsbygoogle || []).push({});
    var resizeTimer;

    function resizer() {
    googletag.pubads().refresh([window.Leaderslot]);
    }

    window.addEventListener(“resize”, function(){
    clearTimeout(resizeTimer);
    resizeTimer = setTimeout(resizer, 250);
    });

  • sbrewitt
    Permalink to comment#

    I think this is the better way to post my previous question. Apologies.
    I’m not a developer at all but trying – thank you to everyone who’s posted here. It’s helped me. Can anyone tell me what I have two ads returned in this code? Or how I need to correct it? Very grateful. You an see the code here:

    http://codepen.io/anon/pen/EVPaZJ

  • Sean Cannon
    Permalink to comment#

    I turned all these into LESS mixins – enjoy : https://github.com/aliencreations/responsiveless

  • Diogo
    Permalink to comment#

    If any one have doubts and window’s sizes etc… Place this JavaScript alert to kwon all informations about window sizes(width and height) and device pixel ratio to help to develop better your mediaqueries. Thank You

    JavaScript code:

    alert(
    “Device PixelRatio: ” + window.devicePixelRatio +
    “\nDevice Width: ” + window.innerWidth +
    “\nDevice Height: ” + window.innerHeight
    );

    *NOTE: “\n” it’s equal to break line, btw :)

  • TB
    Permalink to comment#

    There are duplicate queries for ipad mini and ipad 1-2 which is a bit confusing.

  • Chip
    Permalink to comment#

    I am making a website but don’t know which pixel values to put in my CSS. What would you suggest be the three most basic width ranges?
    For example:

    @media screen
    and (min-device-width: ???px;)
    and (max-device-width: ???px;)
    
    
  • Trevor
    Permalink to comment#

    Using device specific viewports is not very forward thinking. I agree with the ideas in this article:
    https://responsivedesign.is/articles/why-you-dont-need-device-specific-breakpoints

  • Troy
    Permalink to comment#

    Awesome…this is exactly what I was looking for.

  • Anurag
    Permalink to comment#

    What’s the difference between min width and min device width?

    Web designing training

  • Appso
    Permalink to comment#

    I need media query for windows Microsoft/Nokia lumia 520 and above.

    Please help me.

  • Bruno Amaral

    Are the queries updated?

    Post says it hasn’t been updated since 2010…

  • Maruthi
    Permalink to comment#

    Awesome! This helped me a lot.

  • gad
    Permalink to comment#

    Wow is great your tutorial to understand better the term media for the mobiles, this my responsive for my two sites:

    /* MENU */

    @media (max-width: 820px) {

        #plus-haut {display:none}
        .haut_bloc{display:none}
        #reseaux{display:none}
    
        .bloc_responsive{
    
            /* background-color:#15497d; */
            background-color:#67aabf; 
            background-repeat:repeat;
            width:100%;
            height:100%;
        }
    
    
    
        .haut_bloc_responsive {
            padding-left:0px;
            text-align:center;
            left:0px;
        }
    
        .haut_bloc_responsive img{
           margin-top:20px;
           margin-top:10px;
        }
    
        .haut_bloc_responsive li {
            list-style:none;
            font-family:'font-h2';
            font-size:20px;
    
    
        }
    

    #tel-mobile {
    font-size:30px;
    line-height:20px;
    font-weight: bold;
    color : white;
    width:110%;
    margin-top:20px;
    }

    #title-header-mobile{
    font-size:20px;
    line-height:40px;
    font-weight: bold;
    color : white;
    }

        .menu-responsive {
        font-size:18px;
        font-family:'font-h2';
        color:#FFFFFF;
        margin-top: 2px;
        margin-left: 0px;
        padding-left:5px;
        margin-bottom:0px;
        display: inline-block;
        text-align:left;
        }
        .menu-responsive2 {
        text-decoration:none;
        font-size:22px;
        font-family:'font-h2';
        margin-top: 0px;
        margin-left: 10px;
        margin-right:40px;
        padding:0px; !important margin-bottom:0px;
        display: inline-block; 
         float:right;  
    
    
        }
    
        .menu-responsive2 a:link, a:hover, a:active, a:visited  {
            background-color:none; !important
            color:#FFFFFF; !important
            text-decoration:none;
            border-bottom:0px; !important
        }
    

    }

    .menu-responsive-titre li{
    font-size:17px;
    font-family:’font-h2′;
    text-align:center;
    }

    @media (min-width: 820px)
    {
    .haut_bloc_responsive {
    display:none;
    }

    .bloc_responsive{
        display:none;
    }
    
    #fond {
    
        /*  background-color:#15497d;   */
        background-color:#67aabf;  
        background-repeat:repeat;
        min-width:1020px;
    }
    

    }

    http://plombier-sos.com/ and http://serrurier-paris-urgent.com/

    If you have something to improve in my code CCS please let me to know , thank you and please feel free to help to improve this code

  • Vuken Diesel
    Permalink to comment#

    This is very cool how you list every single devices. While is it very useful, it can be very daunting and overwhelming.
    I usually use 4 ranges for my site that it….
    1)smallest for wearable,
    2)smaller for mobile phone,
    3)medium for the tablet, and
    4)large to max for laptop and desktop.

    Thank you again for the detailed list. That is a lot of work and I bow to you sir. Thank you again for awesome works on this site. I learned a lot from this site.

  • Jayesh patel
    Permalink to comment#

    http://eighttech.com/projects/8com/vpage.html

    Please give issues in this URL
    I have some issues in iphone and I have no iPhone device
    Please helps…

  • Julio V.
    Permalink to comment#

    Hi,

    You have wrong device-width for Nexus 7, it’s 960px not 906px.

  • Nate
    Permalink to comment#

    Can you please explain why you used a media query like this? @media (max-width: 48.75em)

  • Shafeequrrahman Khan
    Permalink to comment#

    Hi,

    I want to know, how many type of media screen size.
    Please help me anyone !!!!!!!!

  • Siddharth
    Permalink to comment#

    I wrote a mini library about it, i hope i will develop it more, have a look

  • Sunny
    Permalink to comment#

    In the above post, I see the CSS script up to Iphone 4 to Iphone 6/6 Plus. Looking forward the Resolution ( min and max size) for IPHONE 7 & 7 plus. Could you please share the details.

    /* ———– iPhone 6+ ———– */

    /* Portrait and Landscape */
    @media only screen
    and (min-device-width: 414px)
    and (max-device-width: 736px)
    and (-webkit-min-device-pixel-ratio: 3) {

    }

    /* Portrait */
    @media only screen
    and (min-device-width: 414px)
    and (max-device-width: 736px)
    and (-webkit-min-device-pixel-ratio: 3)
    and (orientation: portrait) {

    }

    /* Landscape */
    @media only screen
    and (min-device-width: 414px)
    and (max-device-width: 736px)
    and (-webkit-min-device-pixel-ratio: 3)
    and (orientation: landscape) {

    }

  • Alex Brown
    Permalink to comment#

    “If you think responsive’s simple, I feel bad for you son. We got 99 viewports, but the iPhone’s just one.
    —Josh Brewer, March 10, 2010”

    Love that quote, mind if I use it on my site?

  • User
    Permalink to comment#

    Using device-height and device-width, respectively min/max-device-height and min/max-device-width is deprecated per MDN

  • Reply
  • Nate
    Permalink to comment#

    It seems like all you really have to do now is design your website to break wherever it looks good using a desktop computer and Chrome web inspector tools.

    Whatever the heck happens with retina and other high pixel density displays doesn’t seem to matter since apparently they make their higher amount of pixels display as if it’s the same amount of pixels as a regular display.

    Based on this, 768px still seems a reasonable breakpoint for tablets and 480px and 320px seems to be a reasonable breakpoint for phones. Whether those dimensions are actually 1.5x, 2x, 3x or higher on retina-like displays doesn’t seem to matter as far as media queries are concerned.

  • Simon Robertson

    Personal opinion here of course, but your website really shouldn’t care what device it is running on. CSS media queries should be used to adjust the website layout, and possibly visual style, to provide the best user experience possible for the device screen resolution (viewport size). Break points, if that’s your thing, can be determined based on the height of the viewport at runtime (100% HTML element height, or a calc() derived from it, etc).

    If you really need to provide device-specific content, using JavaScript or a server-side script to query the user agent string is one solution, but it isn’t super reliable due to the fact the user agent string can be easily changed.

    Design for the viewport, not for the device :)

  • Dylan
    Permalink to comment#

    You say don’t use device specific media queries and then give us a bunch of device specific media queries. That has me a little confused.

  • Dylan
    Permalink to comment#

    I am using LESS, and I want to know how I can combine media queries into a variable to create a general “mobile” media query (ranging from the smallest popular viewport on the market to the largest popular viewport size on the market)? Any ideas?

  • Suil Kumar
    Permalink to comment#

    Hello dear everyone
    how are you

    I recently started a blog. I do not have good knowledge of CSS. Which is why the speed of my website is very slow. Suggest me so that my website’s speed is up and Google starts searching. Provide CSS code for mobile, tablet, desktop, and laptop. I sincerely hope you will help me.
    please help

    My website
    http://www.ohknowledge.com/

  • James
    Permalink to comment#

    I see this was last updated October 9, 2017. Sorry to be greedy, but do you have an update to include Samsung Galaxy S7 and S8?
    I too am just getting started with this part of responsive design (I already use flex layout and rem units). I greatly appreciate this page and it’s device-specific content. For me, it’s like a holstered sidearm as I walk into this minefield of devices. I hope I never have to use it, but I’m glad it’s there.
    It’s also a good way to understand popular devices and to then lump them into groups via more generalized media queries. It’s useful data.

  • Cara Manual
    Permalink to comment#

    Thank you all for helping me find a suitable size for all devices.

    Suggestions if you are still hesitate to determine the appropriate screen size, first check your visitors mostly using what kind of smartphone or what tablet using google analytics. After that you can specify some screen sizes suitable for your web.

  • Web Design Kent
    Permalink to comment#

    Excellent post, thank you. One thing to ask, I want to target specific sizes/devices is it better to use 1 stylesheet with the various breakpoints added or call separate stylesheet specific to that device?

  • Alex Pricope
    Permalink to comment#

    Hi,

    Very nice your post and is very helpfull. I arrived here because on suggestion to my project.

    I have on my code these media querries and I am not sure how can improve it

    @media only screen and (max-width: 640px) {
     .title-logo {
       display: block;
       margin-left: auto;
       margin-right: auto;
     }
     .title-super {
       text-align: center;
     }
     h4 {
       text-align: center;
     }
    }
  • Eugene Rayner
    Permalink to comment#

    Mate, why not use min-device-width + min-device-height? I’ve tried the media queries and got stuck when I got to iPhoneX. Spent a few hours and realised I can get much better results with min-device-height.

    Cheers

  • Robert Wildling
    Permalink to comment#

    Shouldn’t this post be updated to use min-resolutionand max-resolution?

  • Andrew
    Permalink to comment#

    What about 27″ 5K iMac Retina?

  • sara
    Permalink to comment#

    i wanna to make page responsive should i start with phone size first

  • Marcelo
    Permalink to comment#

    Hey
    I noticed the iPad Pro 10.5 have the same min-device-width and max-device-width. Is that correct?

    @media only screen
    and (min-device-width: 834px)
    and (max-device-width: 834px)
    and (orientation: portrait)
    and (-webkit-min-device-pixel-ratio: 2) {

    }

    /* Landscape /
    /
    Declare the same value for min- and max-width to avoid colliding with desktops /
    /
    Source: https://medium.com/connect-the-dots/css-media-queries-for-ipad-pro-8cad10e17106*/
    @media only screen
    and (min-device-width: 1112px)
    and (max-device-width: 1112px)
    and (orientation: landscape)
    and (-webkit-min-device-pixel-ratio: 2) {

    }

  • sai
    Permalink to comment#

    could you please provide media query to target ipad pro 11 inch

  • yogesh

    how to make website responsive on mobile browser(beyond chrome,for ex.vivo browser)

  • Pmakos
    Permalink to comment#

    Are these queries count as mobile first queries?

  • Stephanie
    Permalink to comment#

    You may want to note somewhere here that device-width and device-pixel-ratio are now deprecated:

  • horácio
    Permalink to comment#

    Even interesting this text, I was looking for information related to device sizes / css and I managed to find this information here !! thank you very much!

  • Mitsuki Youko
    Permalink to comment#

    But… what about monitors? Will you guys have a list for all/most monitor sizes? like 21″ 27″ 32″ etc?

  • Vishal Verma
    Permalink to comment#

    Can anybody tell how to achieve css for ipads 10.5 & 12.9 version as css stated above is not working

  • thuanphuocdilink21
    Permalink to comment#

    Could you let me know which i start with phone size first to make page responsive

  • a clearing in a forest
    Permalink to comment#

    Can you collapse the comments so scrolling isn’t “a smidge = shooting past the phone I was trying to see”? I noticed you’ve updated the layout which helps tremendously but it would be awesome to use my wacom pen to scroll without crying.

  • Harry
    Permalink to comment#

    We have recently launched a new website that uses responsive design.
    However we are hearing from some users that the site is not responsive on some mobile devices: HTC’s, Window’s phones, etc.

    When I test in an emulator the devices highlighted the site looks fine, but still for some devices it seems not to work.

    Any ideas?
    https://www.servertrafficweb.com/offshore-dedicated-server.html

  • D7460N
    Permalink to comment#

    Thank you for this article and all the comments. Very informative.

    I have two questions.

    Are rem units for font-size recommended with media queries? Or are other unit types better (like px) with media queries?
    What are the “gotchas” (if any) for offloading media queries to their own external style sheet from an already lengthy style sheet?

    Thanks again!

  • Sam Lalani
    Permalink to comment#

    Is there any way to tell the physical size of the device in inches (or cm)? For example, a resolution of 2532×1170 could exist for a smartphone that is 5″ by 2.5″, or for a mini tablet that is 7″ by 3.5″, which could also be the dimensions of a large smartphone. Or a tablet that is 10″ by 5″. Knowing the physical size of the device would be helpful to determine the size of images to display. For a smartphone, you may want to use half the screen for the image, but for a tablet you may want to use a fourth of the screen.

  • alex
    Permalink to comment#

    Is there a way to set up media queries based on device type i.e tablet but not based on pixels, just that it recognizes that it is a tablet and will show the small screen design?

    my example would be an iPad that has a 1200px screen I don’t want it to show the desktop design, but at the same time desktop screens at 1200px should still work with the desktop look.

  • Suliman Danish
    Permalink to comment#

    I have a question I want to show the table contents on a mobile preview as a single table because i have made the table to repeat as much as there is data on the backend but when i open the mobile preview or even on mobile it shows the data the same as it was in the desktop view.how to differentiate this on the base of device.Thanks

  • Rahul Sahota
    Permalink to comment#

    Hello Everyone,

    can you please suggest me,
    How can i check the mac view on desktop window 10

  • Adam S Khan
    Permalink to comment#

    For tablets also see pointer: coarse.

    This discussion was helpful: https://bugs.webkit.org/show_bug.cgi?id=209292

  • William Cotton

    Hello, how do I my text to adjust for different devices? If I do
    it looks good on my laptop but not my phone.
    Is there a way to have it adjust according to the size of the device being used?
    Thank you

  • Leave a Reply

    Your email address will not be published. Required fields are marked *

    Follow Lee on X/Twitter - Father, Husband, Serial builder creating AI, crypto, games & web tools. We are friends :) AI Will Come To Life!

    Check out: eBank.nz (Art Generator) | Netwrck.com (AI Tools) | Text-Generator.io (AI API) | BitBank.nz (Crypto AI) | ReadingTime (Kids Reading) | RewordGame | BigMultiplayerChess | WebFiddle | How.nz | Helix AI Assistant