Best CSS trick I’ve ever needed to know

I often have to put CSS hacks in my HTML (thank you IE6), and when I do, I usually refer to this simple set of rules to help me determine what browsers I need the hack to work for.

Essentially, it boils down to this:

1) A dot in front of a style will cause the style to only be read by IE 6 and IE 7.
2) An underscore in front of the style will cause the style to only be read by IE 6.

See below:

margin-top: 1px; /* All Browsers */
.margin-top: 2px; /* Read by IE6 and IE7 only */
_margin-top: 3px; /* Read by IE6 only */

Here’s a link to the original post.

Enjoy.

Leave a Reply