1

I'm working with a dynamic stylesheet, ie: style.php, beginning with the code

<?php header('Content-type: text/css'); ?>

How should I comment in such a file?

From my own experience, html style commenting tends to cause some trouble (deactivating upcoming styles) whereas css style commenting tends to be ignored.

On the other hand, Notepad++ colors the html comments green, while leaving the css comments black.

Anyway, if there's an official answer, or some special rules, I'd like to know.

Thanks.

4

2 回答 2

3

如果您希望注释出现在生成的 CSS 中,请使用 CSS 注释,如下所示:

echo "/* My css comment */";
echo "body { margin: 0 }";

如果您不希望它们在生成的 CSS 中可见并且只希望在编辑 PHP 文件时能够读取它们,请使用常规 PHP 注释:

// Just a regular PHP comment, this won't be visible in the generated CSS!
echo "body { margin: 0 }";
/* You can use this style of comments too, it's up to you what you prefer. */
于 2013-04-27T15:35:19.627 回答
0
<?php
    header('Content-type: text/css');

    echo "* { margin: 0; }";
    // Comments 1
    # Comments 2
    /* Comments 3 */
?>
于 2013-04-27T15:31:35.313 回答