2 ms·
I believe you can also just write <![CDATA[whatever]]>. (See https://stackoverflow.com/questions/3302648/should-i-use-cdata-in-html5 https://stackoverflow.com/q
by derefr 4y ago
I believe you can also just write <![CDATA[whatever]]>. (See https://stackoverflow.com/questions/3302648/should-i-use-cdata-in-html5 https://stackoverflow.com/questions/3302648/should-i-use-cda...). It's normally only used to wrap non-HTML content inside <style> and <script>; but you could put "HTML that should be rendered as text" in there as well!
- missblit 4y agoNote that CData can _only_ be used what HTML calls foreign content. So `<math><![CDATA[x<y]]></math>` will print x<7, but `<p><![CDATA[x<y]]></p>` will emit a `cdata-in-html-content` parse error (your compliant HTML parser is allowed to give up here if it's lazy) and is parsed as `<p><!--[CDATA[x<y]]--></p>` (your HTML parser will actually do this because giving up leads to poor user experience when no one else does)