This page looks plain and unstyled because you're using a non-standard compliant browser. To see it in its best form, please upgrade to a browser that supports web standards. It's free and painless.

Robert Marcano's blog
Get Firefox Use OpenOffice.org hacker emblem

Nice workaround for IE CSS bugs

robert | 20 June, 2004 12:52

Recently I have been doing some changes to the CSS files on this site. I wanted to eliminate the page width of the default template of plog, now the site uses the browser window width.

While developing the changes, I tested with Mozilla (and derivatives) and Konqueror, everything worked perfectly, until I restarted my computer in order to do the required Internet Explorer test, as I expected it does not looked right.

I investigated for a nice workaround to the IE bugs that does not need client or server side browser sniffing, and found this feature of IE called Conditional Comments

This feature is activated when the page uses standard HTML/XML comments with an special format, when IE detects them they will be shown according to the IE version that is being used or ignored.

The following example includes a CSS file only if the browser is IE 6 or superior:

<!--[if gte IE 6]>
  <link rel="stylesheet" href="/plog/styles/marcanoonline-ie.css" type="text/css"/>
<![endif]-->

Any other browser (many of them with better CSS support than IE) will ignore the comment and the stylesheet will not be loaded

Comments

Add comment
 authimage
 
Valid XHTML 1.0 Strict and CSS.
Copyright 2003-2009 Robert Marcano. All Rights Reserved
Powered by LifeType