CSS Comments

CSS Comments


Comments In CSS 
Why use comments-
  • Commented lines do not execute while everything else executes.
  • To make it more readable.
  • Comments can be used to explain code in CSS
  • It can also be used to prevent execution when testing alternative codes.
Comments can be placed within style sheets. Style sheets use the comment syntax used in C programming (/*comment*/) 
Syntax - 
We can put anything between the - “/*    */” “//   ”forward slash star and star forward slash.
Example -
<style type="text/css">

p
{
font-face: Courier;
font-size: 14px;
font-weight: bold;
background-color: yellow;
}
// This is a comment used to explain the code

/* THis will not be visible on the output, but people can see in the code be careful before using them*/

</style>
Output - 
 
HTML comment syntax () does not apply in CSS. However, as discussed previously in the “Style Inclusion Methods” section, HTML comments are often used to mask style blocks - 
<style type="text/css">
<!--
p {font-size: 1.5em
font-family: Georgia, "Times New Roman", Times, serif;
color: blue; 
background-color
yellow;}
 --
Types of comments-
We have two types of comments given as follows-
1. Single line comments-
We can make a single line of code into comment
// This is a CSS comment 
div 
color: red;
 // This is a CSS comment 
}
2. Multi-Line comment 
We can make multiple lines into comments
/* This
Is
a
CSS
comment */
div
{
color: red;