How to apply stylesheet only to iPhone (not IE), without browser?

Id like to apply the stylesheet exclusively to the iPhone without having to crawl the browser (via the user agent string) on ​​the server or through JavaScript.

I especially do not want Internet Explorer to use a stylesheet. Apples have suggested code for applying a specific iPhone stylesheet, that is:

<link media="only screen and (max-device-width: 480px)" href="small-device.css" type= "text/css" rel="stylesheet"> 

seems to be causing styles to apply to IE 7 and 6.

+4
source share
1 answer

Use Apple's suggested code, but wrap it in conditional comments to hide it from IE:

 <!--[if !IE]><!--> <link media="only screen and (max-device-width: 480px)" href="small-device.css" type= "text/css" rel="stylesheet"> <!--<![endif]--> 

Credit I think Sitepoints is an article for developing an iPhone for this.

+15
source

All Articles