HTML and CSS Reference
Many people saw IE conditional comments as bad, because they are a propri-
etary feature invented by Microsoft to allow developers to target HTML, CSS, and
for all kinds of evil and represent the sort of “feature” that was probably originally
invented by He-Man's arch nemesis, Skeletor (he also invented IE behaviors, the
IE6 rendering engine, and soap operas).
But they are also very useful for modern web development practices if you
need to target some CSS specifically at older versions of IE to fix rendering bugs
and want to prevent browsers that don't need those fixes from wasting bandwidth
or HTTP requests. Here is a reminder of what they look like. In my template I've
included this code:
<!--[if lt IE 9]>
The entire structure is wrapped in a standard HTML comment, so any browsers
that aren't IE will conveniently ignore the whole block. IE will treat it like an if
statement, running the code if the browser matches the condition contained in
the first line of the comment. In this example, the conditional logic is if lt IE 9 ,
which means “if less than IE9”—so the script will be passed to any version of IE
earlier than IE9. The [endif] part then marks where the conditional content ends.
Note that you can have as many of these IE conditional comments as you like
inside your HTML. The most common ones you'll use are:
if IE . Gives the content to all versions of IE.
if IE 6 . Gives the content to the specified version of IE only.
if lt IE 9 . Gives the content to all versions of IE earlier than the specified
version of IE.
if lte IE 8 . Gives the content to the specified version of IE and all earlier