|
-
Feb 12th, 2011, 07:57 AM
#5
Re: Some questions about CSS
2) no, you do not have to use HTML comments (<!-- -->). They were used back in the day to hide CSS from browsers that didn't know what CSS is. Today finding such a browser is a big task, so you don't need to have the comments there.
XHTML is a bit different though! Contents of style & script elements have been defined in such a way that content needs to be defined as CDATA and commented. Atleast if you don't want a validator to complain about non-XML contents. To do this:
Code:
<style type="text/css">/*<![CDATA[*/
CSS HERE
/*]]>*/</style>
Code:
<script type="text/javascript">/*<![CDATA[*/
JAVASCRIPT HERE
/*]]>*/</script>
Basically this works so that XML CDATA definition prevents complaints about CSS or JavaScript code being invalid XHTML, while CSS & JavaScript comments (/* comment */) prevent the CDATA part being parsed as CSS or JavaScript code.
Ugly, but it does the job. You don't have this problem if you use external CSS and JavaScript files, as stated by Justa Lol.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|