sKunKbad Posted November 30, 2007 Share Posted November 30, 2007 Is there any real value to declaring CDATA sections like this: <script type="text/javascript"> //<![CDATA[ document.cookie = "js-enabled=yes"; //]]> </script> and here: <style type="text/css" media="screen"> /*<![CDATA[*/ * { margin:0px; padding:0px; font-family:Verdana, Arial, Helvetica, sans-serif; } /*]]>*/ </style> I've never heard of a browser having a problem with a document that didn't have the character data wrapped in CDATA section markers, and it doesn't do anything for validation, so what's the deal? Quote Link to comment https://forums.phpfreaks.com/topic/79514-cdata-sections-and-xhtml-doctypes/ Share on other sites More sharing options...
Daniel0 Posted November 30, 2007 Share Posted November 30, 2007 CDATA is data which, by an XML parser, is supposed to be interpreted as character instead of markup. E.g. <![CDATA[<sender>John Smith</sender>]]> should be interpreted as had it been written like this: <sender>John Smith</sender> Similarly, <![CDATA[©]]> should be interpreted as an ampersand followed by copy followed by a semi-colon (i.e. what is literally written) while © should be interpreted as the character ©. That is the purpose of CDATA. It's a way of ensuring that content between e.g. <script> tags won't be interpreted as markup and therefore "ignored" by the parser. Quote Link to comment https://forums.phpfreaks.com/topic/79514-cdata-sections-and-xhtml-doctypes/#findComment-402767 Share on other sites More sharing options...
sKunKbad Posted November 30, 2007 Author Share Posted November 30, 2007 I understand what you are saying, but I've just never had an issue with leaving out the cdata markers. I tried to see if I could use the cdata markers to make a pre type output, but it didn't work. Quote Link to comment https://forums.phpfreaks.com/topic/79514-cdata-sections-and-xhtml-doctypes/#findComment-403096 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.