Should I use <![CDATA[...]]> in HTML5?

Darryl Hein picture Darryl Hein · Jul 21, 2010 · Viewed 32.5k times · Source

I'm pretty sure <![CDATA[...]]> sections can be used in XHTML5, but what about HTML5?

Answer

hollsk picture hollsk · Jul 21, 2010

The CDATA structure isn't really for HTML at all, it's for XML.

People sometimes use them in HTML inside script tags because it removes the need for them to escape certain special characters. It’s by no means a requirement, though (for either HTML 4 or 5).

Edit: This is where we open that really mouldy old can of worms from 2002 over whether you're sending XHTML as text/html or as application/xhtml+xml like you’re “supposed” to :-)