C.4. Embedded Style Sheets and ScriptsUse 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.

Senior Member

joined:Mar 8, 2003
posts:1429
votes: 0

I prefer to always use external stylesheets. Internal or inline style information has to be downloaded with each and every page. But using an external stylesheet instead gives the browser the opportunity to cache it.

Thus reducing the time my users wait for subsequent pages and (slightly) reducing the load on my server.

Senior Member

joined:Mar 15, 2002
posts:6807
votes: 0

I agree with you. I prefer external style sheets (and scripts) too. However, there are times when an internal style sheet is needed... and there are still a lot of people using comments in their internal style sheets. Almost every day someone posts a question on here with a problem related to this.

Preferred Member

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 <!-- ... -->.