Embedded CSS and HTML comment tags

  •  02-11-2009, 4:35 PM

    Embedded CSS and HTML comment tags

    We are having an issue where our users are editing HTML and their styles are not being applied correctly in the editor.  We have tracked this down to them having HTML comment tags around the style sheet definition.  However, the HTML that they are using renders correctly in Internet Explorer and is perfectly valid as far as I can tell.
     
    This renders correctly in the editor:
     
    <html>
        <head>
            <style type="text/css">
            body {  font-size: 9pt;  color: #ff0000; font-family: Arial;}
            p {  font-size: 9pt;  color: #ff0000; font-family: Arial;}
            </style>
        </head>
        <body>
            <p>This text should be 9pt, color #501912 and font family: arial</p>
        </body>
    </html>
     
     
    However, this does not:
     
    <html>
        <head>
            <style type="text/css">
            <!--
            body {  font-size: 9pt;  color: #ff0000; font-family: Arial;}
            p {  font-size: 9pt;  color: #ff0000; font-family: Arial;}
            -->
            </style>
        </head>
        <body>
            <p>This text should be 9pt, color #501912 and font family: arial</p>
        </body>
    </html>
     
     
    As I said, if you view the second example outside the editor in IE, it renders properly.  Many people code their style sheets this way and so it is causing us a bunch of problems.
     
    Is there a reason the editor behaves this way and is there a way around it other than telling our users to not put comment tags around their style sheets?
     
    Thanks,
    --nick
     
     
View Complete Thread