Closed Bug 284488 Opened 20 years ago Closed 20 years ago

HTML comments in <STYLE> section cause following style to be omitted

Categories

(Firefox :: General, defect)

x86
Linux
defect
Not set
trivial

Tracking

()

RESOLVED INVALID

People

(Reporter: robert, Assigned: bugzilla)

References

()

Details

User-Agent:       Mozilla/5.0 (X11; U; Linux i686; en-GB; rv:1.7.5) Gecko/20041110 Firefox/1.0
Build Identifier: Mozilla/5.0 (X11; U; Linux i686; en-GB; rv:1.7.5) Gecko/20041110 Firefox/1.0

If you put HTML comments <!-- hi there --> in the <STYLE> section of an html
document then the style immediately following the comment seems to be missed out.

If I use CSS comments /* hi there */ then the problem goes away.

Seen in Firefox 1.0 on Windows and Linux. Works fine in Opera and IE.

Reproducible: Always

Steps to Reproduce:
Save the following as test.html then view it.

<html>
<head>
<style>
.test {
position: absolute;
left: 10px;
top: 50px;
}

.test2 {
position: absolute;
left: 110px;
top: 160px;
}
<!-- a style -->
.test3 {
position: absolute;
left: 210px;
top: 260px;
}

</style>
</head>

<body>
<h1>A bug?</h1>

<div class="test">
<p>Para 1</p>
</div>

<div class="test2">
<p>Para 2</p>

</div>

<div class="test3">
<p>Para 3</p>
</div>

</body>
</html>
Actual Results:  
Para 3 doesn't use the correct style info and ends up right on para 1.

Expected Results:  
Para 3 should be at the bottom right.

I know this is a candidate for 'well just don't use html comments there then'. I
don't know the W3C specs well enough to know if HTML comments are valid in style
sections. Also I don't know of any web sites that do this - I just found it
while coding my own. But still, thought you might be interested.
Error: Expected ',' or '{' but found '-->'.  Ruleset ignored due to bad selector.
Source File: data:text/html,<html><head><style>.test {position: absolute;left:
10px;top: 50px;}.test2 {position: absolute;left: 110px;top: 160px;}<!-- a style
-->.test3 {position: absolute;left: 210px;top: 260px;}</style></head><body><h1>A
bug?</h1><div class="test"><p>Para 1</p></div><div class="test2"><p>Para
2</p></div><div class="test3"><p>Para 3</p></div></body></html>
Line: 1
Status: UNCONFIRMED → RESOLVED
Closed: 20 years ago
Resolution: --- → INVALID
You need to log in before you can comment on or make changes to this bug.