* html #div { selector:value; } |
Sometimes !important can be useful for overriding dynamically added inline styles (e.g. like when changing CSS rules with jQuery). That’s about the only time I ever use it, I never put it into a stylesheet 😀
]]>No – in this particular instance, there’s no way around.
]]>_height: 500px; /* IE6 */ min-height: 500px; |
I’m not sure which approach is better… ‘!important’ may be the better option here, to be honest.
@Shane, that really sucks about .NET. Can’t those “controls” be changed or configured somehow?
]]>E.g.
margin: 2px 0 0 3px !important; /* good browsers */
margin: 7px 0 0 3px; /* IE6 only */
The control framework inserts markup requesting the control CSS after any CSS you’ve referenced in the head section (whether it’s by referencing a stylesheet or inline CSS – eugh 🙂 ).
The only way to override the controls’ CSS is by using important. It’s not something that I like doing, and this is a specific ASP.NET example, but it’s where I have had to use !important.
]]>Sometimes, you can’t escape from the !important (min-height on IE6) but of course, you need to know what you’re doing.
]]>