Robi wrote:
Gus Richter wrote in message news:5r********************@golden.net...
Xah Lee wrote:
what does it mean when a style tag gives something like the following?
<style type="text/css" media="screen,projection">/*<![CDATA[*/ @import
"/style/monobook/main.css"; /*]]>*/</style>
is this standard?
Yes, it is to mark a section as CDATA as described in XHTML 1.0 Appendix
C, however, he is commenting out the CDATA marked section tags.
I thought it should be like this using all the "hacks" needed for older
browsers:
<style type="text/css" media="screen,projection"><!--/*--><![CDATA[/*><!--*/
@import "/style/monobook/main.css";
/*]]>*/--></style>
You have some errors and omissions in your code sample.
You are thinking of pre-level 4 browsers that did not understand the
style element, where you would use the HTML comment <!--...--> to
comment out the _embedded_ stylesheet section so that it would not be
set as text. This is not needed for today's browsers. Anyone using
vintage browsers and/or Lynx are probably used to seeing such junk. If
you care enough, then you should not be using XHTML anyway and use HTML
where it is OK to comment out the CSS declarations for the CSS
challenged browsers.
What the original code segment showed is using CSS comment /*...*/ to
comment out the CDATA marked opening tag /* <![CDATA[ */ and the
CDATA marked closing tag /* ]]> */ for some reason, likely that the
author realized that they are not needed for his _external_ stylesheets,
wasn't quite sure and left it there just in case he did need the CDATA
marked tags after all, in which case he would remove the CSS comments.
The following is what XHTML 1.0 Appendix C says on the subject:
Script and Style element contents must be wrapped within a CDATA marked
section to avoid expansion of entities < and & as start of markup and
not to recognize < and & as < and & respectively.
<script>
<![CDATA[
... unescaped script content ...
]]>
</script>
An alternative is to use external script and style documents.
For compatibility with existing HTML 4 user agents, use external style
sheets or external script if either uses < or & or ]]> or --.
Note: The historical practice of "hiding" scripts and style sheets
within comments for backward comptibility is likely to not work as expected.
--
Gus