Make them work for you!

By Harry →
Make them work for you!

Are you sick to the back teeth of having to design/develop to the standards of Internet Explorer? Well now it's your chance to tell them what's what, in the simplest way imaginable. In fact, it's so simple, you'll kick yourself...
It utilities CSS and conditional comments to load a different stylesheet for IE users, which displays them a polite message, urging them to get Firefox perhaps.

Firstly make a file named index.html and add the following:

<title>IE Message</title>
<link rel="stylesheet" type="text/css" href="style.css" />
<!--[if IE]><link rel="stylesheet" type="text/css" href="iestyle.css" /><![endif]-->
<div id="ie_message">Hello IE users,get a decent browser!</div>
<div id="box">Everyone should see this!</div>

This is the basis of the page. You can see the conditional comments which have purposely been put after the link to the general stylesheet. As you can see it is very basic, and the only message that example will display is "Hello IE users,get a decent browser!" in Internet Explorer. Your page can be as detailed as you wish. Put links in there to newer versions of IE, links o the FF site, all sorts!

Now for the CSS

Here we will create the stylesheet "style.css". This stylesheet will be used in all browsers, even IE.

font-family: sans-serif;
border:1px solid #0099ff;

This will hide the IE Message div, so users running anything but IE won't be bugged by a message that doesn't even apply to them. There are also the style definitions for the rest of the page.

Finally for the Internet explorer stylesheet. This will make sure that the message gets displayed in all versions of IE. Create the stylesheet "iestyle.css" and fill it with the following:


display:block !important;


The "display:block;" will ensure the message gets displayed, and the "!important" will over-ride and styles defined elsewhere, such as the "display:none" that was defined in the default stylesheet "style.css". See a live demo here.

The advantages of using this method over say JavaScript browser detection is the fact that you can add as much detail and styling as you like to your message, which, when done with JS, will leave you with cumbersome code that may not even work. Secondly, this method will always work, whether JS is disabled on a users browser or not.

Hope that was useful, post a link if you decide to implement it.

Post Tags:

Toon Creffield

Graphic and Digital Designer from Sheffield England and owner of the Estetica Design Forum.

No Comment to " Make them work for you! "