Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CSS3 Media Queries

What is the difference between these two instructions?

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

and

@media only screen and (max-device-width: 480px) {} 
like image 910
Miki Avatar asked Jan 11 '12 18:01

Miki


People also ask

What is the use of media queries in CSS3?

Media queries in CSS3 extended the CSS2 media types idea: Instead of looking for a type of device, they look at the capability of the device. Media queries can be used to check many things, such as: width and height of the viewport. width and height of the device.

What are CSS3 media types?

Media Types in CSS: There are many types of media types which are listed below: all: It is used for all media devices. print: It is used for printer. screen: It is used for computer screens, smartphones, etc.

Do media queries go in CSS?

Media queries are commonly associated with CSS, but they can be used in HTML and JavaScript as well. There are a few ways we can use media queries directly in HTML.

How many media queries should I use in CSS?

You can also have more than one breakpoint for CSS selectors. You might add on additional media queries to continue changing the h1 size as the viewport increases to 62em (992px) and 87em (1392px) wide. You can create as many breakpoints as you would like, and you can use any width that you would like.


1 Answers

The keyword ‘only’ can also be used to hide style sheets from older user agents. User agents must process media queries starting with ‘only’ as if the ‘only’ keyword was not present.

From http://www.w3.org/TR/css3-mediaqueries/

In real use scenarios, the only screen query is used to target specific mobile browsers that support modern CSS.

From http://www.alistapart.com/articles/return-of-the-mobile-stylesheet

Even more clearly

Prefixing a media queries with the "only" keyword will cause non CSS3-compliant browsers to ignore the rule.

From http://www.html5rocks.com/en/mobile/mobifying.html

like image 118
Jason Gennaro Avatar answered Sep 30 '22 13:09

Jason Gennaro