Welcome to WebmasterWorld Guest from

Forum Moderators: httpwebwitch

Message Too Old, No Replies

Ampersands. HTMLencode, or CDATA?

a choice with nuances



7:08 pm on Jun 13, 2008 (gmt 0)

WebmasterWorld Administrator httpwebwitch is a WebmasterWorld Top Contributor of All Time 10+ Year Member

CDATA in attributes is forbidden.
Ampersands in attributes are forbidden.
Ampersands anywhere except CDATA are forbidden.
So if I have data that potentially contains an ampersand, I have two options:


<book title="Withnail &amp; I"/>
<book title="Griffin &amp; Sabine"/>
<book title="Love &amp; Marriage"/>

or this

<book><title><![CDATA[Withnail & I]]></title></book>
<book><title><![CDATA[Griffin & Sabine]]></title></book>
<book><title><![CDATA[Love & Marriage]]></title></book>

which would you choose?
and why?


10:31 am on Jun 14, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member

I use the first method which works for me without any problems.



5:11 pm on Jun 17, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member

I ditto Marshall.

Featured Threads

Hot Threads This Week

Hot Threads This Month