473,386 Members | 1,698 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

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

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
xa*@xahlee.org
∑ http://xahlee.org/

Sep 10 '05 #1
8 4053
"Xah Lee" <xa*@xahlee.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, but afaik the
syntax used there is wrong, see http://www.hixie.ch/advocacy/xhtml

--
Spartanicus
Sep 10 '05 #2
Spartanicus <in*****@invalid.invalid> writes:
"Xah Lee" <xa*@xahlee.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.
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
Sep 10 '05 #3
Chris Morris <c.********@durham.ac.uk> 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.
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
Sep 10 '05 #4
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?

Xah
xa*@xahlee.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
Sep 10 '05 #5
Spartanicus <in*****@invalid.invalid> wrote:
I think that you are confusing the quoted CDATA construct with the old


Brainfart, sorry.

--
Spartanicus
Sep 10 '05 #6
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>

Sep 10 '05 #7
On Sat, 10 Sep 2005 16:12:27 GMT, Spartanicus <in*****@invalid.invalid>
wrote:
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.

Sep 10 '05 #8
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 &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
Sep 11 '05 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Bill Davy | last post by:
I am working with MSVC6 on Windows XP. I have created an MSVC project called SHIP I have a file SHIP.i with "%module SHIP" as the first line (file is below). I run SHIP.i through SWIG 1.3.24...
5
by: Jeremy Clulow | last post by:
Hi I was looking at the source code of a site which had the code below in the <head> section. Could someone please explain whether this is a known and effective way of compensating for...
11
by: Mark | last post by:
Hello I made a site with validated XHTML and CSS. It works fine also. Only in IE i see the site build up without CSS (very fast though) and then the CSS is used to build the page. When i use...
1
by: chris | last post by:
Confused somewhat xml newbie. I'm trying to output xml with a CDATA section, using saxutils.XMLGenerator, but the output contains escaped '<' and '>' and '&' from the CDATA element. Shouldn't it...
4
by: Schraalhans Keukenmeester | last post by:
I recently discovered the value of tidy for my html adventures. Nice little app. Only one thing is becoming a bit of a drag. If I use tidy to clean up my code, it inserts the following in every...
18
by: sim.sim | last post by:
Hi all. i'm faced to trouble using minidom: #i have a string (xml) within CDATA section, and the section includes "\r\n": iInStr = '<?xml version="1.0"?>\n<Data><!]></Data>\n' #After i...
4
by: gimme_this_gimme_that | last post by:
I've seen this include at several sites. Is this documented somewhere? Briefly - how does it work? Thanks.
9
by: shapper | last post by:
Hello, Why do some pages I have seen have //<![CDATA[ in the beginning of a script tag before the script itself? Do I need this? Thanks, Miguel
6
by: dkyadav80 | last post by:
Hi sir, I'm new about xml, javascript. I have two selection field(html) first is city and second is state. the city and state values should be store in xml file. when user select city then all...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.