Fix: Textareas containing markup for not rendering

by "Alexander J. Vincent" <jscript(at)pacbell.net>

 Date:  Sat, 21 Jul 2001 10:02:33 -0700
 To:  hwg-techniques(at)hwg.org
  todo: View Thread, Original
Well, I managed to figure it out.  This bears remembering.

On July 10, 2001, I posted a message here saying W3C HTML Validator just
wouldn't validate an XHTML textarea containing markup.  The definition for a
textarea's contents are #PCDATA, meaning parsed character data.
Technically, markup must still be parsed in this section.

But,

<textarea rows="1" cols="1">
<![CDATA[
<html>
...
</html>
]]>
</textarea>

works and validates.  The reason is the CDATA tags turn their contents into
unparsed character data.  As long as the interior of the CDATA tags doesn't
contain a ]]>, I can put in as much markup as I want.

So, now I simply need to escape ]]> into ]]&gt; for any files the server
sends to the client via textareas.

Ah, well.  It's so hard to remember the difference between #PCDATA and
<![CDATA[...]]>.  Cheers, and thanks to Mr. Oskoboiny for putting up with me
(and being correct, after all...)

Alex Vincent
Vallejo, CA

HWG hwg-techniques mailing list archives, maintained by Webmasters @ IWA