CSS Comment Tutorial

G:hackHTMLmyCSS-Tutorial12-comment�1.jpg

When we want to explain portion of our source code within the source itself we can use comment block.

The structure of a comment is like this:

/* comments */

You can use multiple lines for comments like this:

/*

Comments

Comments

Comments

…

*/

Just make sure you start your comments with “/*” and end comments with “*/”.

Example:

<!DOCTYPE html>
<html>
<head>
<title>CSS is fun :)</title>
<style type="text/css">

/* comments… */

li:not(#li1){

/* comments… */

background-color: red;/* comments... */
}

/* comments… */

</style>
</head>
<body>
<ul>
<li id="li1">List Item one</li>
<li id="li2">List Item two</li>
</ul>
</div>
</body>
</html>

Note: if you are using internal CSS, you can only put your comments within the body of <style> </style> element. But within this element, you are free to put your element wherever you want.