Welcome to WebmasterWorld Guest from

Forum Moderators: open

Message Too Old, No Replies

Ampersands. HTMLencode, or CDATA?

a choice with nuances

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

Senior Member from CA 

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

joined:Aug 29, 2003
votes: 0

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 June 14, 2008 (gmt 0)

Senior Member from US 

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month

joined:Sept 4, 2001
votes: 46

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


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

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Feb 21, 2005
posts: 1526
votes: 0

I ditto Marshall.

Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members