Reputation: 331
I style the page with a style element in the head element, but when I comment out a line, the next line under it is also affected. For example:
<head>
<meta charset="utf-8">
<title>title</title>
<style>
h1 {
<!-- font-weight: normal; -->
text-align: center;
}
</style>
</head>
I comment out font-weight in the above code, but when I run it on the browser(Firefox and IE), text-align is also canceled out. The text editor I use is Notepad++. What happened?
Upvotes: 0
Views: 48
Reputation: 2092
If you really must use HTML commenting style, you can change your code to the following:
<head>
<meta charset="utf-8">
<title>title</title>
<!-- font-weight: normal; to be used in stylesheet maybe -->
<style>
h1 {
text-align: center;
}
</style>
</head>
And I added some text after your stylesheet comment so that you'll remember what it is. I'd recommend making the decision before making the page containing this code live to the world or users will be downloading a few unnecessary extra bytes of nothing.
Upvotes: 0
Reputation: 222
This type of commenting is not allowed in stylesheets so the style breaks.
Try it this way:
/* font-weight: normal; */
Upvotes: 4
Reputation: 944171
The style element contains CDATA. It cannot contain markup. An HTML comment is a CSS syntax error. A CSS comment begins with /*
and ends with */
.
Upvotes: 1