Click to See Complete Forum and Search --> : XHTML 1.0 Strict Content Data


Xeenslayer
02-03-2003, 05:34 AM
Hi all. I'm rather interested to "upgrade" my HTML from XHTML 1.0 Transitional to Strict.

I have several problems. First, I heard that internal JavaScript code and CSS code have to be commented out. I tried using a convertor before and the new XHTML code (Transitional) uses this:

<style type="text/css">
/*<![CDATA[*/

css code here....

/*]]>*/
</style>

However from what I read in HTML Goodies, I suppose it is no longer like this?

I tried something like that but it doesn't work:

<style type="text/css">
<![CDATA[

css code...
</style>

Another question, about comments. Since <!-- COMMENT --> Cannot be used in XHTML Strict, what should I use? I tried

<![CDATA[ COMMENT ]]>

but it's an error and the comment is displayed on the page.
]]>

Robert Wellock
02-04-2003, 09:43 AM
Normally using <!-- Some Comment --> will work although it is best to use external files.

You cannot have JavaScript that uses certain characters like the double dash delimiter -- within the script itself if it is contained within an XHTML page, or it thinks it is a comment, try this:

<script type="text/javascript">
//<![CDATA[
<!-- Begin JavaScript

// End Hiding -->
//]]>
</script>

Xeenslayer
02-05-2003, 04:28 AM
Um... comments and external files??

Robert Wellock
02-05-2003, 10:55 AM
An example of an external JavaScript link:

<script type="text/Javascript" src="somescript.js"></script>

An example of an external CSS link:

<link rel="stylesheet" href="somefile.css" type="text/css" />

An example of an internal JavaScript

<script type="text/javascript">
//<![CDATA[
document.write('<p>Hello<\/p>');
//]]>
</script>

Alternatively you could have this:

<script type="text/javascript">
<!--
document.write('<p>Hello<\/p>');
// -->
</script>

Or combine the two as I originally wrote, basically <!-- Some JavaScript Code //--> is the old method.

Xeenslayer
02-09-2003, 04:53 AM
Ok I get it. :) So do we have to comment out internal CSS code using this as well?

PS. My question was on writing comments. I thought <!-- COMMENTS --> isn't allowed in XHTML strict?