How to add comments in the style sheet blocks


You may need to put additional comments in your stylesheet blocks. Therefore, it is very easy to comment any part of the style sheet. You can simply put your comments inside /*.....this is a comment in style sheet.....*/.

You can use /* ....*/ to comment multi-line blocks in a similar way you do in C and C++ programming languages.

Let us see how to add a comment:

<!DOCTYPE html>
<html>
   <head>
      <style>
         p {
            color: red;
            /* This is a single-line comment */
            text-align: center;
         }
         /* This is a multi-line comment */
      </style>
   </head>
   <body>
      <p>Hello World!</p>
   </body>
</html>

Samual Sam
Samual Sam

Learning faster. Every day.

Updated on: 30-Jan-2020

178 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements