Targeting IE only with CSS


I got a question from Jeff yesterday asking me about a CSS tag that he’d never seen before, and in fact, neither had I. 


What he saw was this:

*html someclassname
{
   properties in here
}
*html Anotherclassname
{
   properties in here
}


I started to do some investigation and see what I could find out.  I checked one of my favourite CSS Books (Web Standards Solutions: The Markup and Style Handbook), nothing, I tried to search on http://search.msn.com and http://www.google.com and nothing.  (It is kind of hard to search for *html when you actually want * not the wildcard!)


I emailed Dan Cederholm (the author of the book above) and he graciously replied with the answer this morning.  It’s a way of targeting CSS to only Windows IE.  IE believes that there is a wrapper element around the HTML block, and thus applies these rules to the block.  Great if you need to fix a CSS rendering issue in Windows IE.


I’ve also posted some new Night photos at http://www.bigbackpack.ca/ngallery/albums/Night+and+Low+Light+(July+21%2c+2005).aspx 

Comments (5)

  1. Jeff Parker says:

    Cool thanks Pete this is indeed very helpful and a useful thing as well a way to specifically target CSS for IE.

  2. Another trick for doing the same thing:

    .differentSize {

    width: 100px;

    -width: 200px;

    }

    IE will for some reason ignore the leading "-" and treat the second line as if it just said "width: 200px". Other browsers will correctly ignore the whole line.

    You can stick a "-" in front of any css property to have all browsers except IE ignore it.

  3. Jeff Parker says:

    Oh Pete on another note your night images are great, I really like the one of the ship. But you know one thing that would be nice is if you could make these handy wallpaper sizes. 1024 X 768 I am capable of cropping it and did I liked it enough to make it my wallpaper for a while. However your the artist I might not have cropped it exactly where you would have. Just a suggestion.

  4. PeteLe says:

    If I were to make them 1024×768, I’d just end up adding black borders to the sides. I shoot with a square format camera, which gives me a bit of a differentiation than 35mm.

Skip to main content