Conditional Comments – Spawn or Saviour?

Having found out IE10 will No Longer Support Conditional Comments, I wondered if version 1.3 of the W3’s Markup Validator supported them yet. Turns out it’s a no (surprise surprise)…

However: looking more closely at MSDN’s article on downlevel hidden / revealed comments (yes: buzzwords alert!) I notice that the Validator only complains about proper downlevel comments…

Try this out in the Direct Input page of the Validator (not sure if Unicorn says the same thing, I don’t see why not):

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head><title></title></head>
<body>
<!--[if IE]><p>You are using Internet Explorer.</p><![endif]-->
<![if !IE]><p>You are not using Internet Explorer.</p><![endif]>

<!--[if IE 7]><p>Welcome to Internet Explorer 7!</p><![endif]-->
<!--[if !(IE 7)]><p>You are not using version 7.</p><![endif]-->

<!--[if gte IE 7]><p>You are using IE 7 or greater.</p><![endif]-->
<!--[if (IE 5)]><p>You are using IE 5 (any version).</p><![endif]-->
<!--[if (gte IE 5.5)&(lt IE 7)]><p>You are using IE 5.5 or IE 6.</p><![endif]-->
<!--[if lt IE 5.5]><p>Please upgrade your version of Internet Explorer.</p><![endif]--><!--[if true]>You are using an <em>uplevel</em> browser.<![endif]-->
<![if false]>You are using a <em>downlevel</em> browser.<![endif]>
<!--[if true]><![if IE 7]><p>This nested comment is displayed in IE 7.</p><![endif]><![endif]-->
</body></html>

You should see (turning “Output” on) the lines 8 and 19 are the naughty ones.

To my mind this indicates that the Validator is simply invalidating through syntactical inaccuracy; rather than any voodoo that some detractors may be suggesting…

The above code doesn’t even preclude frontend dev’s from using downlevel sniffing; as the concatenation between arguments is used in the cojoining variety above to include simultaneous uplevel and downlevel sniffing!

Advertisements

Tags: , , ,

About Nick

House-husband, ex-KUSECWB, graduate & techie-monsta / computer-wrangler; at your service.
%d bloggers like this: