CSS for IE 8 Only

。_饼干妹妹 提交于 2019-12-02 07:33:43

It does not mean "If IE 8 or lower".

<!--[if IE 8]>

Means if it is IE8

<!--[if lt IE 8]>

If it is less than IE 8

<!--[if lte IE 8]>

If it is less than or equal to IE 8

If you do as in your example, IE8 will get mystyleIE8.css and IE7 will get mystyleIE7.css.

These are called conditional comments. You could use other syntaxes for other scenarios. In this example:

<!--[if lte IE 7]>
stuff
<![endif]-->

the "stuff" would only apply to all versions of Internet Explorer 7 and lower.

For more, see http://www.quirksmode.org/css/condcom.html, for example.

KatieK is correct. If you look inside the comments:

if IE 8

Means "If the browser is IE version 8", which includes only IE8.

if IE 7

Means "If the browser is IE version 7", which includes only IE7.

There's syntax that DOES allow less than. But what you showed isn't it. Contrast with

if lte IE 8

Means "If the browser is less than or equal to IE version 8", which includes IE8, IE7, IE6, and IE5.5.

if lte IE 7

Means "If the browser is less than or equal to IE version 7", which includes IE7, IE6, and IE5.5.

You can try the following CSS Hacks. Interesting stuff.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!