Browsers are improving and although it’s getting a little bit easier to develop for each of them without spending too much time targeting them individually, that doesn’t mean that we’re done maintaining applications built on older versions.
Specifically, older versions of Internet Explorer have often required more time that we’d like to admit when it comes to making sure our experiences are consistent across the board.
And as much as I dislike introducing hacks into my code (and would rather leverage conditional comments), there are three easy ways to target each version of Internet Explorer.
Internet Explorer 6: The Underscore-Hack
This is somewhat of an old hack, but still works when it comes to applying a style strictly to IE6. The underscore hack will target IE6-only:
#container {
background: #000;
_background: #fff;
}
Internet Explorer 7: The Star-Hack
Similar to the underscore hack, the star-hack (or asterisk-hack) can be used to target IE78 an all previous versions:
[cc lang=”css”]
#container {
background: #000;
*background: #fff;
}
[/cc]
Internet Explorer 8: The Slash-Hack
Finally, IE8 offers the “/9″ hack to target it and any prior versions:
[cc lang=”css”]
#container {
background: #000;
background: #aaa9;
}
[/cc]
Again, I can’t say that I’m a huge fan of using hacks like this but there are certain instances where this is more effective than creating separate stylesheets for the sake of a single line.
Additionally, this is obviously one of the very first code-related posts. As we’re looking to expand code-specific content, what would you be interesting in seeing?
Ben Miller says
Is there a way for us to include code in the comments here? Is there a way to edit our comments once they are posted?
I think this blog, more so than the other 8BIT blogs, could really use both of those features. I’d like to comment on this post, but I’m not sure how to include code in my comment, and I don’t want to screw it up experimenting. 🙂
Tom says
Currently, your comment is live and final once it’s been posted. I like those ideas, though. We’ll definitely look into what options we have.
For now, try putting your code in code tags:
They'll appear like this.
Herb says
thanks for the tip.
Concerning other “coding” issues, I love to see some wordpress theme customization related coding
Tom says
Awesome. Exactly the kind of feedback we’re looking for ;).
Look for more to come..!
Steven Rossi says
Agreed on the WordPress-specific code snippets. I think that’d be really helpful.
Actually, come to think of it, although there are lots of other tutorials online about this subject, it’d be great to see a comprehensive post that lists all of the ways to target IE with CSS.
Also, I think posts about HTML5 and CSS3 would be particularly timely. Maybe you could do a series on how to begin incorporating these into your (church?) site.
Tom says
Love the suggestions. Definitely gonna plan for some of these.