Skip to content
uencoder

HTML CDATA

HTML CDATA wraps content containing < and & inside <script>/<style> with <![CDATA[...]]> in XHTML to avoid parsing errors.

Purpose

To embed content with XML special characters in XHTML script/style elements without escaping.

Mechanism

XHTML is XML, so a < inside a script would be treated as the start of a tag; CDATA wrapping prevents that. In HTML5, script/style content already has CDATA semantics and needs no explicit wrapper.

Use cases

  • Inline scripts in XHTML
  • Inline styles in SVG
  • XML-compatible HTML

Related tools

References