Mike,
You might find it easier to use the Modernizr script to detect
JavaScript (amongst other tests it runs to see the capabilities of a
browser) and then apply a similar method to what you have described
here, but on the body tag instead.
<!DOCTYPE html>
<html lang="en" dir="ltr" class="no-js">
<head>
<title><!-- Enter a title here --></title>
<meta charset="utf-8">
<!--[if ! lt IE 6]><!-->
<link rel="stylesheet" href="/styles/screen.css" media="screen,
projection" />
<link rel="stylesheet" href="/styles/print.css" media="print" />
<!--<![endif]-->
<!--[if gte IE 6 ]>
<link rel="stylesheet" href="/styles/ie.css" media="screen, projection" />
<![endif]-->
<script src="/scripts/modernizr-1.5.min.js"></script>
</head>
<!--[if lt IE 6 ]> <body class="iex"> <![endif]-->
<!--[if IE 6 ]> <body class="ie6"> <![endif]-->
<!--[if IE 7 ]> <body class="ie7"> <![endif]-->
<!--[if IE 8 ]> <body class="ie8"> <![endif]-->
<!--[if IE 9 ]> <body class="ie9"> <![endif]-->
<!--[if (gt IE 9)|!(IE)]><!-->
<body>
<!--<![endif]-->
Modernizr replaces the class of no-js in the HTML tag, with js when
JavaScript is present. This combined with the conditional statements on
the BODY tag will couple to give you what you require.
http://www.modernizr.com/
Kevin Rapley
DigiKev
0772 345 7862
digikev.co.uk <http://digikev.co.uk>
On 28/10/2010 14:21, Foskett, Mike wrote:
Hi All,
I was wondering if you had a little time to comment on the following
technique?
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<!--[if IE]>
<![if gt IE 8]><html lang="en-gb" class="gtIE8" xml:lang="en-gb"
xmlns="http://www.w3.org/1999/xhtml"><![endif]>
<![if IE 8]><html lang="en-gb" class="IE8" xml:lang="en-gb"
xmlns="http://www.w3.org/1999/xhtml"><![endif]>
<![if IE 7]><html lang="en-gb" class="IE7" xml:lang="en-gb"
xmlns="http://www.w3.org/1999/xhtml"><![endif]>
<![if IE 6]><html lang="en-gb" class="IE6" xml:lang="en-gb"
xmlns="http://www.w3.org/1999/xhtml"><![endif]>
<![endif]-->
<!--[if !IE]><!--><html lang="en-gb" class="xIE" xml:lang="en-gb"
xmlns="http://www.w3.org/1999/xhtml"><!--<![endif]-->
<script
type="text/javascript">/*<![CDATA[*/document.documentElement.className+="
hasJS";/*]]>*/</script>
... yada ...
<style type="text/css">
body {background:#ccc; color:#000}
.IE8 body {background:#fcc;}
.IE7 body {background:#cfc;}
.IE6 body {background:#ccf;}
.xIE body {background:#fff;}
</style>
... yada ...
Not thoroughly tested I admit but it appears reasonable.
The only failure I can see is detecting IEv6 and JS on because:
.IE6.hasJS {background:#f000}
will not work as IE 6 cannot concatenate class names.
What do you think?
Regards,
Mike Foskett
http://websemantics.co.uk/
------------------------------------------------------------------------
This is a confidential email. Tesco may monitor and record all emails.
The views expressed in this email are those of the sender and not Tesco.
Tesco Stores Limited
Company Number: 519500
Registered in England
Registered Office: Tesco House, Delamare Road, Cheshunt, Hertfordshire
EN8 9SL
VAT Registration Number: GB 220 4302 31
*******************************************************************
List Guidelines: http://webstandardsgroup.org/mail/guidelines.cfm
Unsubscribe: http://webstandardsgroup.org/join/unsubscribe.cfm
Help: memberh...@webstandardsgroup.org
*******************************************************************
*******************************************************************
List Guidelines: http://webstandardsgroup.org/mail/guidelines.cfm
Unsubscribe: http://webstandardsgroup.org/join/unsubscribe.cfm
Help: memberh...@webstandardsgroup.org
*******************************************************************