Reputation: 3114
I have a page, where I need to show help text based on the version of the IE. I have decided to use conditional comments as per this blog. My html page looks like this ...
<!DOCTYPE html>
<html>
<head>
<title>Application Title</title>
<meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1">
</head>
<!--[if lt IE 9 ]><body style="margin: 0px;" class="ie9lt"><![endif]-->
<!--[if IE]> <body style="margin: 0px;" class="ie9"> <![endif]-->
<!--[if (gt IE 10)|!(IE)]>-->
<body style="margin: 0px;"><!--<![endif]-->
<div id="id1">
....
....
</html>
I have opened this file on IE 9 but checked the html by inspect the elements option but my body element didn't have ie9 class (for that matter no class) associated with it. Am I missing something here? Please help
Upvotes: 0
Views: 3956
Reputation: 6865
you can try to be more specific en work on the root HTML tag:
<!doctype html>
<!--[if IE 7 ]><html lang="en" class="ie7"><![endif]-->
<!--[if IE 8 ]><html lang="en" class="ie8"><![endif]-->
<!--[if IE 9 ]><html lang="en" class="ie9"><![endif]-->
<!--[if (gt IE 9)|!(IE)]><!-->
<html lang="en">
<!--<![endif]-->
Upvotes: 1
Reputation: 26829
I've checked your HTML with IE9 and it works perfectly fine. I can see that body
has ie9
class.
Can you see the same in HTML inspector as below? Also, is your browser mode set to IE9?
Sometimes, when you have errors in your HTML document IE automatically switches to Compatibility View mode and then your body
class is ie9lt
(and not ie9
).
Upvotes: 1
Reputation: 7576
I'd only put style definitions in those comments, nothing else. Let the html document stay as clean as possible. That's probably one of the most messy implementations of that hack there is.
Upvotes: 0