Conditional comments are comments that only work on windows default browser - Internet Explorer (IE), but are ignored by other browsers like Google Chrome or Firefox.
They are supported from Explorer 5 onwards, and you can use them to give conditional instructions to different versions of IE.
Below is an example:
<!DOCTYPE html>
<html>
<head>
<title>Scholars Conditional Comments</title>
<!--[if IE 6]>
Special instructions for IE 6 here
<![endif]-->
</head>
<body>
<p>Body content goes here.....</p>
</body>
</html>
You will find your self in situations where you need to apply a different style sheet based on different versions of Internet Explorer, in such situation conditional comments will be useful.
Using the comment tags to comment a part of HTML code, you must take note of browser differences, there are few browsers that support the <comment> tag to comment a part of HTML code.
For Example
<!DOCTYPE html>
<!DOCTYPE html>
<html>
<head>
<title>Scholars Conditional Comments</title>
<!--[if IE 6]>
Special instructions for IE 6 here
<![endif]-->
</head>
<body>
<p>Body content goes here.....</p>
</body>
</html>
You will find your self in situations where you need to apply a different style sheet based on different versions of Internet Explorer, in such situation conditional comments will be useful.
Using the comment tags to comment a part of HTML code, you must take note of browser differences, there are few browsers that support the <comment> tag to comment a part of HTML code.
For Example
<!DOCTYPE html>
<html>
<head>
<title>Scholars Globe Tag</title>
</head>
<body>
<p>This is <comment>not</comment> Internet Explorer.</p>
</body>
</html>
If you are using IE, then it will produce following result:
This is Internet Explorer.
But if you are not using IE, then it will produce following result:
This is not Internet Explorer.
<head>
<title>Scholars Globe Tag</title>
</head>
<body>
<p>This is <comment>not</comment> Internet Explorer.</p>
</body>
</html>
If you are using IE, then it will produce following result:
This is Internet Explorer.
But if you are not using IE, then it will produce following result:
This is not Internet Explorer.
No comments:
Post a comment