CSS Tutorial - CSS Comments








Comments are used to explain your code and they are ignored by browsers.

A CSS comment begins with "/*", and ends with "*/", like this:

/*This is a comment*/
p{
   color:red;
   text-align:center;
}

Example

The following code uses CSS comments in a html document.

<!DOCTYPE HTML> 
<html> 
    <head> 
        <style type="text/css"> 
        /*This is a comment*/
        p{<!--   w  w  w .  j a va  2 s.  c  o  m-->
           color:red;
           text-align:center;
        }
        </style> 
    </head> 
    <body> 
        <p>Visit the website</p> 
    </body> 
</html>

Click to view the demo





Example 2

We can even put comment among the declaration.

<!DOCTYPE HTML> 
<html> 
    <head> 
        <style type="text/css"> 
        p{<!--  w  w w .j  ava  2  s. c o m-->
           color:red;
           /*This is a comment*/
           text-align:center;
        }
        </style> 
    </head> 
    <body> 
        <p>Visit the website</p> 
    </body> 
</html>

Click to view the demo