I was recently asked how you could include different CSS on a page for different browsers without resorting to javascript. Whilst conditional comments are no use outside of Windows IE browser, this is usually the browser that most people need to target (due to required CSS work-arounds).
I have put together a quick reference for the use of conditional comments here:
faq215-6625
The following code shows how a conditional comment can be used to match "all versions of IE less than version 7" and include an extra css file and an extra div in the content of the page:
This is described in more detail, along with an example that shows javascript variables being set using conditional comments, on the FAQ.
Cheers,
Jeff
[tt]Jeff's Page @ Code Couch
[/tt]
What is Javascript? FAQ216-6094
I have put together a quick reference for the use of conditional comments here:
faq215-6625
The following code shows how a conditional comment can be used to match "all versions of IE less than version 7" and include an extra css file and an extra div in the content of the page:
Code:
<html>
<head>
<link href="default.css" type="text/css" rel="stylesheet" />
<!--[if lt IE 7]>
<link href="iexplore.css" type="text/css" rel="stylesheet" />
<![endif]-->
</head>
<body>
<h1>Testing</h1>
<!--[if lt IE 7]>
<div>I'm an old IE running in Windows</div>
<![endif]-->
</body>
</html>
Cheers,
Jeff
[tt]Jeff's Page @ Code Couch
[/tt]
What is Javascript? FAQ216-6094