Forum Moderators: not2easy
<style type="text/css">
<!--...
//-->
</style>
<!--
<style type="text/css">...
</style>
//-->
However, XML compliant browsers (version 6/7 or later) are allowed to silently remove any content within these comments. This might cause unexpected results!
Note that it doesn't matter whether your page follows HTML, XHTML, or XML - the problem is the same. Therefore, do not use comments in your style sheets!
The same goes for JavaScripts...
Reference: [w3.org]
C.4. Embedded Style Sheets and Scripts
Use external style sheets if your style sheet uses < or & or ]]> or --. Use external scripts if your script uses < or & or ]]> or --. Note that XML parsers are permitted to silently remove the contents of comments. Therefore, the historical practice of "hiding" scripts and style sheets within "comments" to make the documents backward compatible is likely to not work as expected in XML-based user agents.
Thus reducing the time my users wait for subsequent pages and (slightly) reducing the load on my server.
`-->` is used with a STYLE element.
`//-->` is the technique in the inside of a SCRIPT element.
Both are frequently used by people in the <style> element. However, both are equally incorrect CSS syntax (which is why they are ignored by browsers).
External CSS is wonderful! I wish more people would listen to your advice :)
You are hiding the <style> tag from some browsers by having it inside a comment.
The correct format is always: <tag><!-- details --></tag>
Any browser that does not uderstand tag, ignore it. It will ignore the comment too. but <!--<tag> details <tag>--> means that all browsers should ignor the whole statement. You are also nesting the < and > symbols which may confuse some browsers, it shouldn't but it might.
You also state not to use comments within stylesheets. This needs clarifiying. Styles in the HTML require the comment tags as in your first example but without the '//' (as stated before this is needed for JavaScript only). Comments in an exernal stylesheet should be of the format /*....*/ and NOT <!-- ... -->.
Comments:
1: HTML: <!-- ... -->
2: Style: /* ... */
3: JavaScript: // ...
4: Perl: # ...
It's no wonder it's can become confusing.
So are you saying this affects .xml files only, or .html as well? Because I have never seen the problem.
There is even no necessity of commenting out, in HTML.
This technique is for the browser which does not understand a STYLE element.
In XML(includes XHTML), the contents of a STYLE element are #PCDATA.
Therefore, `<!-- ... -->` is truly treated as a comment, the contents from `<!--` to `-->` is not parsed.