开发者

Are there W3C-compatible hacks for IE6 and 7?

开发者 https://www.devze.com 2023-02-15 01:10 出处:网络
Are there valid hacks in IE6 and 7 for W3C compatibility? I believe there are W3C incompatibilities when using hacks. For example, using the following CSS code (as sugges开发者_如何学编程ted under op

Are there valid hacks in IE6 and 7 for W3C compatibility?

I believe there are W3C incompatibilities when using hacks. For example, using the following CSS code (as sugges开发者_如何学编程ted under option 2 in this article: http://webdesignerwall.com/tutorials/css-specific-for-internet-explorer?cp=1):

.box {
    height:200px;
    _height:200px;
}

gave me the following error in the W3C CSS validator:

Property _height doesn't exist : 200px 200px

If I'm wrong please advise.

Thank you.


This alternative hack should do it:

/* Both of the following will be used by IE only. */
* html .box{height:200px;} /* IE6 only */
*+html .box{height:200px;} /* IE7 only */


Options 1 and 3 in that article — i.e. HTML conditional comments — are the way to go. They don’t trip up the HTML validator, and they’re explicit — they say “use this code for this version of IE”.

You can use them to apply different stylesheets that only fix Internet Explorer bugs. This keeps your IE bug workarounds separate, so that when, for example, the IE6 countdown reaches zero, you can remove your IE 6-specific CSS without affecting anything else.

0

精彩评论

暂无评论...
验证码 换一张
取 消