Tutorial - Some Fun With Conditional Tags



Disclaimer:
Conditional Tags now work effectively only on Internet Explorer 9 and earlier.

The Killjoys at Microsoft killed off the use of conditional tags in Internet Explorer 10.



Which sounds, possibly, a bit like the joys of gardening, the delights of housework, the mirth and merriment of painting and decorating, or some similarly gruesome activity; unlikely.

Okay, so this is not a fun thing, per se, more of a curiosity which has the potential to provide wry amusement or mild confusion. And it's all down to the humble conditional tag.


So, what is a Conditional Tag?


Essentially, a conditional tag is a small string of code - typically just a single line - which says "if".

The "if" in question could be one of many things - but in this particular case, the "if" will be designed to instruct the Internet Explorer browser on your computer to do one specific thing - while at the same time, the code will instruct all other browser types to do something else. It's what conditional tags do... and here is but one example;

Having just insulted Chrome, Firefox, Opera and Safari users - on this very page - Internet Explorer users are welcome to have a giggle at their expense; but if you happen to be one of them - i.e. a user of one of those four aforementioned browsers, thinking "WTF is he on about, he's really lost it...."

Try coming back to this page - using Internet Explorer - and you'll then see what I mean.

So how is this done? As I wrote, using a conditional tag. The code which enables this quirk is shown immediately below; copy and paste this code into your HTML document immediately before the content you want to hide...


<!--[if !IE 6] />




...and copy and paste this code at the point where you want your content to become visible again:


<![endif]-->





It's an oldie, but goodie - enjoy!




Back To Tutorials Page




Martin Kearns' Home