SGMLXML.net A place for SGML and XML application developers.

March 22, 2006

The Underscore Hack

Filed under: CSS — cangione @ 6:36 pm







We all know that IE is not the best at supporting the web standards. This leads properly coded web pages to look awful at times including this site! My typical web browser is Firefox where the pages on sgmlxml.net look great. I still have some wayward friends that use IE so I was experimenting with making the pages look better in IE.

There are a couple of different techniques talked about on the web for this problem. The one that I prefer after some experimentation is the Underscore Hack. The hack works because IE is not the brightest browser in the world. An underscore in CSS is designed to act as a comment for that attribute only, and all browsers but IE honor this.

.text {
       margin: 10px;
       _margin: 15px;
}

NOTE: You have to place the underscore rule after the real attribute since IE sees both but uses the last one it sees.


No Comments »

No comments yet.

RSS feed for comments on this post. TrackBack URL

Leave a comment

You must be logged in to post a comment.

Powered by WordPress