Computer >> Computer tutorials >  >> Programming >> CSS

CSS Comments


We can write comments for CSS declarations to help improve readability and make it more understandable. CSS follows C language style syntax for comments which start and end with forward slash between which the content is enclosed in asterisks. Any declaration written inside /**/ is ignored.

Syntax

The syntax of CSS comments is as follows −

/*Comments*/

The following examples illustrate CSS comments −

Example

<!DOCTYPE html>
<html>
<head>
<style>
ul {
   list-style: none; /*To remove the solid circles*/
}
</style>
</head>
<body>
<ul>
<li>Σ1</li>
<li>Σ2</li>
<li>Σ3<li>
</ul>
</body>
</html>

Output

This gives the following output −

CSS Comments

Example

<!DOCTYPE html>
<html>
<head>
<style>
div {/*this <div> selects all >div> elements and the declares the following*/
   margin: 8px;
   float: left;
   width: 100px;
   height: 100px;
   /*border: 2px solid black;*/
   /*removed border*/
   background-color: lightpink;
}
div + div { /*this makes a circle*/
   border-radius: 50%;
}
</style>
</head>
<body>
<div></div>
<div></div>
</body>
</html>

Output

This gives the following output −

CSS Comments