internet explorer - How does one target IE7 and IE8 with valid CSS? -
I want to target IE7 and IE8 with W3C-compatible CSS. Sometimes fixing CSS for a version is not good for others. How can I achieve it?
Clearly target hacked versions of IE without using HTML and CSS
Use this approach if you do not want to hack into your CSS. & lt; Html & gt; Add a browser-unique class to the element so that you can choose later on a browser basis.
Example
& lt;! Doctype html & gt; & Lt ;! - [if IE] & gt; & Lt ;! [AndIf] - & gt; & Lt ;! - [If LT IE 7] & gt; & Lt; Html lang = "en" class = "ie6" & gt; & Lt; [Endif] - & gt; & Lt ;! - [If IE 7] & gt; & Lt; Html lang = "en" class = "ie7" & gt; & Lt; [Endif] - & gt; & Lt ;! - [If IE 8] & gt; & Lt; Html lang = "en" class = "ie8" & gt; & Lt; [Endif] - & gt; & Lt ;! - [If IE 9] & gt; & Lt; Html lang = "en" class = "ie9" & gt; & Lt; [Endif] - & gt; & Lt ;! - [if (gt IE 9) |! (IE)]> gt; & Lt ;! - & gt; & Lt; Html lang = "en" & gt; & Lt ;! - & lt ;! [Endif] - & gt; & Lt; Top & gt; & Lt; / Head & gt; & Lt; Body & gt; & Lt; / Body & gt; & Lt; / Html & gt; Then you can use your targeted browser strictly in your CSS.
Example
.i6 body {boundary: 1px solid red; } .7 body {boundary: 1 px solid blue; } Check for more information
Target IE version with CSS "hacks"
For more, here are these hacks that help you target IE versions.
Use "\ 9" to target IE8 and below.
Use "*" to target IE 7 and below.
"_" to target IE6
Example:
Body {boundary: 1px solid red; / * Standard * / Border: 1px solid blue \ 9; / * IE8 and below * / * range: 1px solid orange; / * IE7 and below * / _bidder: 1 px solid blue; IE10 does not recognize the conditional statement of IE10 so that you can use it to implement & lt; Html & gt; element
& lt ;; Doctype html & gt; For "ie10" class & lt; Html lang = "en" & gt; & Lt ;! - [if! IE]> & Lt ;! - & gt; & Lt; Script & gt; If (/ * @ cc_on! @ * / False) {document.documentElement.className + = 'ie10';} & lt; / Script & gt; & Lt ;! - & lt; [Endif] - & gt; & Lt; Top & gt; & Lt; / Head & gt; & Lt; Body & gt; & Lt; / Body & gt; & Lt; / Html & gt;
Comments
Post a Comment