Conditional comments for iPhone

You're probably familiar with IE's conditional comments. They allow us to feed special code to that special browser to overcome its many bugs and deficiencies.

Is there something similar for iPhone? Not exactly, but we can achieve the same end:

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

Some versions of IE will apply stylesheets regardless of the media attribute, so the conditional comments are here merely to tell IE not to use this code.

As for the value of the media attribute: not all browsers understand the "only" keyword; they will simply ignore this line. Of those that do understand it, the only one width a max-device-width of 480px is the iPhone.

(So I'm told. I'm taking all of this on faith. But it seems to work.)

Comments

No comments yet.

Leave a Reply

(will not be published)
(optional)

What My Clients Say

Travis Miller's professionalism and experience is an invaluable asset to Airplane Corporation. His technical development skills are on par with the best in the industry. He completes projects on time and on budget, and is truly a pleasure to work with.

—Christian Childs
Airplane Corporation