I am trying to add comments to my HTML style, but I’m finding that when I add a comment, the styles stop working.
The below works just fine. The icon and the text display in gray.
<html lang="en">
<head>
<title>test</title>
<link href="/gtd/media/css/font-awesome.css" rel="stylesheet">
</head>
<body>
<style>
.action-star {
color: gray;
}
</style>
<div class="container-fluid">
<span class="action-star"><i class="icon-star icon-large"></i> Test Icon</span>
</div><!--/container-->
</body>
</html>
However the below does not work. The icon and the text display in black.
<html lang="en">
<head>
<title>test</title>
<link href="/gtd/media/css/font-awesome.css" rel="stylesheet">
</head>
<body>
<style>
<!-- Comment -->
.action-star {
color: gray;
}
</style>
<div class="container-fluid">
<span class="action-star"><i class="icon-star icon-large"></i> Test Icon</span>
</div><!--/container-->
</body>
</html>
The only thing I added was the line:
<!-- Comment -->
I must be missing something obvious. . .
To make comments in CSS use
/* Comment */, not the HTML<!-- Comment -->syntax. That is what is breaking your CSS.Just as a hint, if you are working in an editor that supports syntax highlighting, usually they will give comments a specific color. The most common colors I have seen for comments are grey, dark blue, or dark green. Of course, this can still vary by editor, but a change in coloring is a good indicator that you are using the proper syntax for a comment.
Look how your
<!--/container-->comment turned grey in your code sample, but<!-- Comment -->didn’t. As you now know, this didn’t happen because you hadn’t used proper syntax.Cheers!