Sunday 3 May 2009

Stylesheets for Different Web Browsers

If you're like me and you are required to keep the websites you develop accessible to 95%+ of your customer base then making patch style sheets is a good way to go. To keep everything neat I develop a site with IE7 and FF3 open, testing in each periodically. At the end of the development process I open ie6 and, after my eyes have finished throwing up, I throw in an ie6 only stylesheet to begin the clear up. This stylesheet is called last so that I can override anything in my other css.


<!--ie 6 only!-->
<!--[if IE 6]-->
<link href="/css/ie6.css" rel="stylesheet" type="text/css">
<!--[endif]-->
<!--/ie 6 only!-->





I like this way of doing things since it makes it a lot easier to dive in and out of, allows me to code the rest of the site free of ie6 restrictions but still lets me cater for those 15% of our visitors that still insist on using ie6. Plus I like the fact that in a year or two, when that 15% is closer to 0%, I can easily remove all my ie6 fixes with a simple edit to my master pages.

Other html if statements include:



<!--[if IE 7]-->
<link rel="stylesheet" type="text/css" href="css/ie7.css">
<!--[endif]-->




IE7 only stylesheet for resolving any ie7 quirks.

<!--[if !IE]-->
<link rel="stylesheet" type="text/css" href="/css/nonIE.css">
<!--[endif]-->



A stylesheet for all browsers except for versions of internet explorer.

No comments: