I’ve defined the following media queries in order to load different .css files for mobile and desktop browsers:
<link rel="stylesheet" type="text/css" media="screen" href="desktop.css" />
<link rel="stylesheet" type="text/css" media="handheld" href="mobile.css" />
But in mobile Internet Explorer I see styles from desktop.css for some reason. Why it is so? How can I fix it?
Usage of
handheldis not reliable in mobile browsers, some mobile browsers (such as Mobile Internet Explorer) usemedia="handheld"if it is the only value defined, but usemedia="screen"by default if both are defined. The hack is to definemedia="Screen", with an uppercaseS, this causes Mobile IE to use thehandheldoption when both are defined.But I’d suggest you to avoid using these media queries as you should rely on screen resolution rather than on mobile browser. For example, Mobile Safari could be on both iPad or iPhones, but you need to style your webiste differently because of different size of the screen. So you can use the following media queries for iPhones:
For iPad
For desktop
Or you can specify media queries directly in .css file
Here are some good articles about it:
http://webdesignerwall.com/tutorials/css3-media-queries
http://www.smashingmagazine.com/2010/11/03/how-to-build-a-mobile-website/
http://coding.smashingmagazine.com/2010/07/19/how-to-use-css3-media-queries-to-create-a-mobile-version-of-your-website/