2. Hiding from unsupporting browsers Make them believe that the data is inside a comment. For example : <style type="text/css"> <!-- body { background: #eee; color: #000; } --> </style>
3. Hiding from unsupporting browsers (Con’t) With the script element, use a single line ECMAScript comment (//) to hide the end token from browsers . For example : <script type="text/javascript"> <!-- function foo () { bar(); } //--> </script>
4. In HTML, their contents are defined as CDATA, meaning everything from the start of the contents to the next occurrence of the closing token (</ in this case) is considered character data that isn't parsed as markup. Parsing differences between HTML and XHTML
5. in XHTML their contents are defined as PCDATA, meaning the contents are parsed as markup. If you wish to include <and& characters in your script or style sheet, you will run into problems. Parsing differences between HTML and XHTML (Con’t)
6. in XHTML, you must mark up a special CDATAsection. So, use the styling or scripting language to comment out the CDATA section markers. Parsing differences between HTML and XHTML (Con’t)
7. For example: Parsing differences between HTML and XHTML (Con’t) <style type="text/css"> /*<![CDATA[*/ body { background: #eee; } /*]]>*/ </style> <script type="text/javascript"> //<![CDATA[ document.title = "Foo & Bar"; //]]> </script>
8. to write XHTML that can also be handled by common HTML user agents as well as old browsers that don't support the styleand scriptelements. Putting the two together <style type="text/css"> <!--/*--><![CDATA[/*><!--*/ body { background: #eee; } /*]]>*/--> </style> <script type="text/javascript"> <!--//--><![CDATA[//><!-- document.title = "Foo & Bar"; //--><!]]> </script>