<!--[if lt IE 7 ]><html class=“ie ie6” lang=“en”> <![endif]-->

前端 未结 4 1342
孤街浪徒
孤街浪徒 2021-01-05 05:44
  1. What does this and other similar IE code lines mean in an HTML5 do

4条回答
  •  天命终不由人
    2021-01-05 06:14

    1. This is a conditional IE statement. They are only read by IE. Any other browser will read them as any normal comment, note the at the beginning and end of the statement respectively. IE has special code that recognizes this comment and uses whats inside the comment as regular HTML. In specific to your pasted code above, the IE conditional statement is applying a class of ie6 to the HTML tag. In this way you can provide IE only fall backs for certain elements by first referencing that class in your css selector. For example .ie6 #header {} will only apply to the header if the IE6 class is present, and that class will only be present in IE6 because of the conditional statement.

    2. Following the same style as above, you would use this bit of code:

    3. You could use an IE stylesheet if you so choose, either way you would achieve essentially the same result. I personally would use the above method with the class on the HTML tag, and then a separate css file that is loaded normally called ie.css. Inside this file, you would have nothing but IE styles. Note that with this method the stylesheet does not need to be setup in a conditional IE statement. It's only real purpose in being a separated stylesheet is for organizational purposes. I would also only do this if you have a moderate to large amount of IE conditional code. If you have minimal IE fall-back code, simply include the code next to your the code it is fixing inside your master stylesheet.

    4. You can also expand IE support to a certain extent using things like Modernizr and Selectivizr

提交回复
热议问题