Questions And Answers

More Tutorials

CSS Media Queries for Retina and Non Retina Screens

Although this works only for WebKit based browsers, this is helpful:


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

There are two types of pixels in the display. One is the logical pixels and the other is the physical pixels. Mostly, the physical pixels always stay the same, because it is the same for all the display devices. The logical pixels change based on the resolution of the devices to display higher quality pixels. The device pixel ratio is the ratio between physical pixels and logical pixels. For instance, the MacBook Pro Retina, iPhone 4 and above report a device pixel ratio of 2, because the physical linear resolution is double the logical resolution.

The reason why this works only with WebKit based browsers is because of

  • The vendor prefix -webkit- before the rule.
  • This hasn't been implemented in engines other than WebKit and Blink


In this page (written and validated by ) you learned about CSS Media Queries for Retina and Non Retina Screens . What's Next? If you are interested in completing CSS tutorial, your next topic will be learning about: CSS Width vs Viewport.

Incorrect info or code snippet? We take very seriously the accuracy of the information provided on our website. We also make sure to test all snippets and examples provided for each section. If you find any incorrect information, please send us an email about the issue:

Share On:

Mockstacks was launched to help beginners learn programming languages; the site is optimized with no Ads as, Ads might slow down the performance. We also don't track any personal information; we also don't collect any kind of data unless the user provided us a corrected information. Almost all examples have been tested. Tutorials, references, and examples are constantly reviewed to avoid errors, but we cannot warrant full correctness of all content. By using, you agree to have read and accepted our terms of use, cookies and privacy policy.