KBD

Keith Devens .com

Friday, January 9, 2009 Flag waving
And this too, shall pass. – often attributed to Abraham Lincoln
← Anime primerSeparate content from presentation →

Daily link icon Friday, August 2, 2002

XHTML

A revised version of XHTML 1.0 has been released. I've never understood why Script and Style elements are #PCDATA instead of #CDATA. I'd love to hear the reasoning behind that.

Also see this HTML compatibiltiy note on Embedded Style Sheets and Scripts.

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

How annoying is that? You're supposed to use external scripts if your script contains a less than character or an ampersand, which we all know rarely if ever turn up in programming. Asses.

You're really supposed to escape the contents of any embedded script with <![CDATA[ .. ]], but as I discovered, that doesn't seem to work in browsers (which is probably why they just tell you to use an external script or stylesheet). Here's my workaround to make my pages with scripts validate: I use the <![CDATA[ crap, but I put it inside JavaScript comments like so:

<script type="text/javascript">
//<![CDATA[
... script goes here ...
//]]>
</script>

This way it validates, and it's totally valid, but doesn't screw up user-agents which don't support the <![CDATA[ crap (and none currently do, AFAIK). Also, this is different than the script "hiding" with HTML comments they mentioned in the quote above. HTML comments aren't valid in JavaScript, but this trick uses JavaScript comments, so there's no problem, nor will there ever be.

← Anime primerSeparate content from presentation →

Comments XML gif


Feel free to post a comment below. Please see my comment policy.

Formatting Rules (No HTML):

  • **bold**, *italic*, _underlined_, --strikeout--
  • "text"="url" creates a link, and URLs are auto-highlighted
  • Blockquote: Like e-mail, begin paragraph with > (greater-than sign)
  • Lists: begin paragraph with *,-, or + (unordered), or # (ordered)
  • Code block: ?!code:language=perl|php|sql|javascript|etc.{\n}...{\n}?!/code

:
(will be your IP address if blank)
: (optional)
(Will not be shown on site)

: (optional)
:

January 2009
SunMonTueWedThuFriSat
 123
45678910
11121314151617
18192021222324
25262728293031



RSS feed RSS feed for Keith's Weblog
Atom feed Atom feed for Keith's Weblog
Weblog archive
Recent comments
  on 3 posts

Recent comments XML

The Elegant Universe

Well I have finally found the crazy​guy that preaches useless nonsence​in A...

Joseph Baxter: Jan 7, 11:07pm

I hate Norton Antivirus


SYMANTEC is very​cunning..
Symantec now have a​redeemable cash back offe...

CAN: Jan 4, 6:25pm

Spider solitaire

Hi everyone!

Glad to have found​this site.  I have enjoyed reading​the c...

flwrchld53: Jan 4, 5:30pm

Generated in about 0.378s.

(Used 8 db queries)

mobile phone