UnderScore Css Trick

UnderScore Css Trick

Postby matrix » Mon Mar 02, 2009 6:11 pm

Browsers are supposed to simply ignore CSS properties that they don’t understand. This much should be obvious. However, IE/Win does its usual trick of trying too hard to cope with user error and will read and process any valid CSS property with an underscore tacked on to the front. All other browsers will ignore the mystery property. Example:

p{
color: black;
_color: blue;
}

All browsers save IE/Win will display the paragraph text as black – IE/Win displays it as blue. It reads the _color property and allows it to replace the one that came before.

I discovered this technique whilst looking for a solution to IE’s lack of support for min-height to specify the minimum height of an object. Decent browsers like Mozilla support this property, but IE doesn’t. Thanks to another IE bug (one that results in overflow being treated strangely), it’s possible to set a minimum height for both IE and proper browsers in a fashion such as this:
:)
div#content{
height: auto;
min-height: 400px;
_height: 400px;
}
matrix
Newbie
Newbie
 
Posts: 8
Joined: Thu Oct 25, 2007 8:58 am

Return to CSS

Who is online

Users browsing this forum: No registered users and 1 guest

cron