tags:

views:

21

answers:

1

What is wrong with my HTML document?

<html>
  <body>
    <p><![CDATA[I can't see this text :(]]></p>
  </body>
</html>

Why don't I see the text inside CDATA?

+3  A: 

Explicit CDATA sections are, in practice, unsupported in text/html documents. They are marked as a feature authors should avoid because they have limited support.

Your browser is probably treating it as an unknown element.

David Dorward
@David Do you know any alternative to `CDATA`? How can I use a potentially ill-formed XML/HTML inside well-formed XHTML document?
Vincenzo
Alternative to CDATA? Replace characters with special meaning with entities. Dealing with ill-formed data? Clean it up before inserting it (maybe with an HTML 5 parser) or reject it if it isn't well-formed at the input stage.
David Dorward
@David I solved the problem by changing the MIME type of the web page from `text/html` to `application/xml`. Now everything works fine.
Vincenzo
@Vincenzo IE doesn't support `application/xml`.
RoToRa