RSS
 

IEMobile Conditional Comment

21 Mar

Did you know you can target the Internet Explorer browser on mobile Windows Phone 7 devices?

<!--[if IEMobile]>
   Displayed only on Internet Explorer Mobile on Windows Phone 7
<![endif]--> 

<![if !IEMobile]>
  Anything else
<![endif]>

You totally can1. Hearts to Allison Wagner for telling me about it.

It's a bit more en vogue to handle mobile styling via media queries, which I generally agree is a better way to handle things (browser agnostic), but has the classic problem of a the browser needing to downloading resources it doesn't need (e.g. CSS for desktop version when on a mobile device).

You know what would be super radical? If we could do media queries within conditional comments.

<!-- [if (min-device-width: 481px)]>

<![endif]—>

That would combine the syntax and power of media queries, with the ability of conditional comments to load only the specific resources we need, staying streamlined in terms of bandwidth.


1 Notice in the first block of conditional comments above the slightly different syntax. The former is called a downlevel-hidden comment and the latter is a downlevel-revealed comment. Nerdgrammer.

 
 

Tags: