It was a good time that I saw in the middle of the css the keyword !important, not really interest me, to finally realize it's a wonderful way to hack IE6, while respecting the standards w3c.
On large web projects, you probably already have encountered problems with css styles that did not apply as you wish before you realize that you applied this style in the wind as it was refined a little further, the overwhelming style 1.
To remedy this, I put up a lot of legacy styles to limit the risk of overload css. The keyword !important is just to prioritize the application of a style to another. Thus if an attribute is defined with the keyword !important at the end of definition and this attribute is redefined below or in an external stylesheet, it will not be overwritten.
Where it becomes very good with our beloved IE6, eternal daemon in xHTML/CSS implementation, is that this poor browser doesn't support this keyword. What it do ? It ignores at all ! We can therefore, from the time keyword respects standards, take this unknowing to hack IE6 :)
Go ! a little css is more effective than a long speech.
html, body, p, form, fieldset, table, { margin:0; padding:0; } body{ background-color:#FFF; font-family: Verdana, Arial, Helvetica, sans-serif; font-size:11px; } ol, ul{ list-style: none; } div#fakeDiv{ display:block; width:300px; height:300px; background-image:url(../Img/test.png) !important; /* non-sucky browser */ background-image:url(../Img/test.gif); /* IE6 */ background-repeat:no-repeat; }
Thus providing a transparent image on high PNG quality on browsers know the keyword !important and less GIF quality on IE6 and below, all without going through <!--[ IF lt IE 7]> or PNG fix.
This example is extensible to any css recurring problem on IE6, including double margin, negative padding, transparency, etc..
en effet ce n'est pas valid W3C, mais dans certains cas (au niveau CSS, jamais en HTML) , car malheureusement IE6 persiste, je passe outre ces normes mais ça reste vraiment exceptionnel.
Bon courage ^_^
Merci pour l'astuce, je ne connaissais pas.
Je viens de regarder, cela marche au poil ; seul truc dérangeant, cela n'est pas valide w3c, !important oui ;)
Bon dev !
il y a aussi cette possibilité :
background:url(..); /* nav normaux ! */
_background:url(..); /* IE6 */
Comme ça on peut encore passer outre le !important !
Bon courage ^^.