I need to show source code examples in a static HTML document. Usually I'd have to escape all occurrences of <
>
and &
to see the code in the browser as intended. Which makes it very hard to write and update. But then I remembered there was that CDATA thing. So I went on and tried it out. But it didn't work, in Firefox and Chrome. The content seems to be parsed and interpreted, not rendered verbatim.
Am I doing it wrong? Am I too late and has the browser support for CDATA disappeared already? Did I misinterpret the documentation? How can I get this to work?
<pre><code><![CDATA[<html>
<input type="text" disabled>Test & more</p>
]]></code></pre>
This shows up as: (with an input box)
[________________]Test & more
]]>