Issue
I am using CSS and HTML. I am using an external stylesheet and a "style" element within the HTML to override the external stylesheet.
My question is: when I put an HTML comment inside the "style" element, then the style does not override the external CSS. However, when I use CSS comments inside the "style" element then it does work. HTML comments belong inside HTML and the "style" element is still HTML, so why do the HTML comments inside the "style" element cause the overrides to fail?
For example:
<html>
<head>
<title>test</title>
<style>
<!-- body{background:#eee;} -->
</style>
</head>
<body></body>
</html>
The above example demonstrates the odd behavior of applying the style in spite of the comment tags.
jsFiddle Demo (tested in Chrome 16.0.912.75 Windows 7)
Solution
CSS is not a markup language. The style block inside your HTML page is an autonomous piece of code. Similar to javascript inside script block. Its not HTML. So HTML comments are not technically comments inside style block.
Answered By - srijan
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.