XML CDATA
A CDATA (Character Data) section wraps raw text in <![CDATA[...]]> so the XML parser does not parse it, letting content with < and & be embedded safely.
Purpose
To embed text blocks containing XML special characters (<, >, &) without escaping each character, common for inline scripts and styles.
Mechanism
Content between <![CDATA[ and ]]> is passed through as character data; tags and entities inside are not parsed. CDATA cannot nest; the sequence ]]> must be split.
Use cases
- Inline JavaScript in XHTML
- Code examples inside XML
- Inline styles in SVG