klenwell
klenwell

Reputation: 7148

How do I properly apply IE conditionals on the html tag for non-IE browsers like Firefox?

I'm trying to apply the technique recommended here for IE detection in jQuery:

https://stackoverflow.com/a/3165521/1093087

What I'm unclear about is how to set the html tag for non-IE browsers.

This is what I currently have in my template:

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
  <head>

Is this what I should replace it with:

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<!--[if lt IE 8><html class="lt-ie8"><![endif]-->
<!--[if IE 8]><html class="ie8"><![endif]-->
<!--[if gt IE 8]><!--><html><!--<![endif]-->
  <head>

Is IE going to be confused by two html tags if I do it that way?

Upvotes: 0

Views: 1705

Answers (1)

spooky
spooky

Reputation: 1648

Try this:

<!doctype html>
<!--[if lt IE 7 ]> <html class="ie6" lang="en-US" 
                        xmlns="http://www.w3.org/1999/xhtml"
                        > <![endif]-->
<!--[if IE 7 ]>    <html class="ie7" lang="en-US" 
                        xmlns="http://www.w3.org/1999/xhtml"
                        > <![endif]-->
<!--[if IE 8 ]>    <html class="ie8" lang="en-US" 
                        xmlns="http://www.w3.org/1999/xhtml"
                        > <![endif]-->
<!--[if IE 9 ]>    <html class="ie9" lang="en-US" 
                        xmlns="http://www.w3.org/1999/xhtml"
                        > <![endif]-->
<!--[if (gte IE 9)|!(IE)]><!-->
<html xmlns="http://www.w3.org/1999/xhtml">
<!--<![endif]-->

You will have CSS for each instance to customize stuff.

Upvotes: 3

Related Questions