HighDots Forums  

style tag with CDATA... @import...

Cascading Style Sheets Layout/presentation on the WWW (comp.infosystems.www.authoring.stylesheets)


Discuss style tag with CDATA... @import... in the Cascading Style Sheets forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Xah Lee
 
Posts: n/a

Default style tag with CDATA... @import... - 09-10-2005 , 07:10 AM






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?

Xah
xah (AT) xahlee (DOT) org
http://xahlee.org/


Reply With Quote
  #2  
Old   
Spartanicus
 
Posts: n/a

Default Re: style tag with CDATA... @import... - 09-10-2005 , 08:07 AM






"Xah Lee" <xah (AT) xahlee (DOT) org> wrote:

Quote:
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?
Something like that is required for XHTML served as XHTML, but afaik the
syntax used there is wrong, see http://www.hixie.ch/advocacy/xhtml

--
Spartanicus


Reply With Quote
  #3  
Old   
Chris Morris
 
Posts: n/a

Default Re: style tag with CDATA... @import... - 09-10-2005 , 11:43 AM



Spartanicus <invalid (AT) invalid (DOT) invalid> writes:
Quote:
"Xah Lee" <xah (AT) xahlee (DOT) org> 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?

Something like that is required for XHTML served as XHTML,
<style type="text/css" media="screen,projection">
@import "/style/monobook/main.css";
</style>
would be better, surely, even for XHTML as XHTML?

Personally I'd rather use that [1] and risk breaking the page slightly in
Netscape 1 and earlier (as if XHTML and half of HTML 4 wouldn't
confuse them enough), than have the unreadable and unmemorable nested
comment that the various specifications require between them.

Quote:
but afaik the syntax used there is wrong, see
http://www.hixie.ch/advocacy/xhtml
Indeed. It's not just decade-old cargo cult baggage, it wouldn't even
have worked properly in the few browsers it was necessary for.

So, I suppose in answer to the OP's question, if you see that in the
style tag it means the author was confused.

[1] Actually, I'd just use <link>, and deal with the NS4/IE4 hiding
another way.

--
Chris


Reply With Quote
  #4  
Old   
Spartanicus
 
Posts: n/a

Default Re: style tag with CDATA... @import... - 09-10-2005 , 12:12 PM



Chris Morris <c.i.morris (AT) durham (DOT) ac.uk> wrote:

Quote:
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?

Something like that is required for XHTML served as XHTML,

style type="text/css" media="screen,projection"
@import "/style/monobook/main.css";
/style
would be better, surely, even for XHTML as XHTML?

Personally I'd rather use that [1] and risk breaking the page slightly in
Netscape 1 and earlier (as if XHTML and half of HTML 4 wouldn't
confuse them enough), than have the unreadable and unmemorable nested
comment that the various specifications require between them.

but afaik the syntax used there is wrong, see
http://www.hixie.ch/advocacy/xhtml

Indeed. It's not just decade-old cargo cult baggage, it wouldn't even
have worked properly in the few browsers it was necessary for.
I think that you are confusing the quoted CDATA construct with the old

<style type="text/css">
<!--
foo{color:white}
-->
</style>

construct meant to prevent very old and by now unusable browsers from
rendering the content of the style and/or script element.

The CDATA construct is based on something else specific to XHTML served
as such IIRC, read Hixie's article for the specifics.

--
Spartanicus


Reply With Quote
  #5  
Old   
Gus Richter
 
Posts: n/a

Default Re: style tag with CDATA... @import... - 09-10-2005 , 01:10 PM



Xah Lee wrote:
Quote:
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?

Xah
xah (AT) xahlee (DOT) org
http://xahlee.org/

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.

--
Gus


Reply With Quote
  #6  
Old   
Spartanicus
 
Posts: n/a

Default Re: style tag with CDATA... @import... - 09-10-2005 , 01:40 PM



Spartanicus <invalid (AT) invalid (DOT) invalid> wrote:

Quote:
I think that you are confusing the quoted CDATA construct with the old
Brainfart, sorry.

--
Spartanicus


Reply With Quote
  #7  
Old   
Robi
 
Posts: n/a

Default Re: style tag with CDATA... @import... - 09-10-2005 , 03:59 PM



Gus Richter wrote in message news:5r6dnVC2vcFfjr7eRVn-rA (AT) golden (DOT) net...
Quote:
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>



Reply With Quote
  #8  
Old   
Andy Dingley
 
Posts: n/a

Default Re: style tag with CDATA... @import... - 09-10-2005 , 06:54 PM



On Sat, 10 Sep 2005 16:12:27 GMT, Spartanicus <invalid (AT) invalid (DOT) invalid>
wrote:

Quote:
The CDATA construct is based on something else specific to XHTML served
as such IIRC, read Hixie's article for the specifics.
Hixie's article is a deliberate bit of poking fun at XHTML - the idea of
how to deal "neatly" with "hiding CSS" when you choose to serve
XHTML-as-XML to an ancient browser, despite the fact you're playing
merry hell with its accept: header.

XHTML needs some careful handling of _scripts_ with a <![CDATA[ ... ]]>
section. But for CSS, just serve rthe stuff and don't worry about it.



Reply With Quote
  #9  
Old   
Gus Richter
 
Posts: n/a

Default Re: style tag with CDATA... @import... - 09-10-2005 , 09:30 PM



Robi wrote:
Quote:
Gus Richter wrote in message news:5r6dnVC2vcFfjr7eRVn-rA (AT) golden (DOT) 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 &lt; and &amp; 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


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.