CSS Comments:-

CSS comments are not displayed in the browser but that can help in your source code for better understanding.

Comments are used to explain the code, they can help you in the future when you will update the code.

Comments are ignored by the browser.

CSS comments are placed in the <style> section and started from /* and end with */.


<!DOCTYPE html>

<html>

<head>

<style>

/*This is a single-line comment*/

p{color: red;}

</style>

</head>

<body>

<p> This is a paragraph.</p>

<p> This is another paragraph in this code CSS comments will not display in the output.</p>

</body>

</html>

Try this code for a better experience 


NOTE:- You can put CSS comments wherever you want in <style> tag.


<!DOCTYPE html>

<html>

<head>

<style>

p{color: red;} /* here red color set for text*/

</style>

</head>

<body>

<p> This is a paragraph.</p>

<p> This is another paragraph in CSS comments you can put CSS comments anywhere you want but only in <style> tag.</p>

</body>

</html>

Try this code for a better experience 


NOTE:- Comments can also span multiple lines.


<!DOCTYPE html>

<html>

<head>

<style>

/*This is 

a multiple 

line comment*/

p{color: red;}

</style>

</head>

<body>

<p> This is a paragraph.</p>

<p> This is another paragraph in this code we use CSS multiple-line comments.</p>

</body>

</html>

Try this code for a better experience 


HTML and CSS comments:-

From the HTML tutorial, you learn about HTML comments you can add comments in HTML using <!-- --> syntax.

In the below code, we will use a combination of HTML and CSS comments.


<!DOCTYPE html>

<html>

<head>

<style>

/*This is a CSS comment*/

p{color: red;}

</style>

</head>

<body>

<p> This is a paragraph.</p> !-- This is HTML comment --!

<p> This is another paragraph in this code we use the combination of HTML and CSS comments for better understanding.</p>

</body>

</html>

Try this code for a better experience