CSS Comments
- Previous Page CSS Usage
- Next Page CSS Colors
CSS Comments
Comments are used to explain the code and may be helpful when you edit the source code later.
The browser will ignore comments.
located <style>
CSS comments within the /*
Start, with */
End:
Examples
/* This is a single-line comment */ p { color: red; }
You can add comments at any location in the code:
Examples
p { color: red; /* Set text to red */ }
comments can span multiple lines:
Examples
/* This is a multi-line comments */ p { color: red; }
HTML and CSS comments
From the HTML tutorial, you learn that you can use <!--...-->
Syntax Add comments in the HTML source code.
In the following example, we combine the use of HTML and CSS comments:
Examples
<!DOCTYPE html> <html> <head> <style> p { color: red; /* Set the text color to red */ } </style> </head> <body> <h2>My Heading</h2> <!-- These paragraphs will be red --> <p>Hello World!</p> <p>This text is styled by CSS.</p> <p>CSS comments will not be displayed in the output.</p> </body> </html>
- Previous Page CSS Usage
- Next Page CSS Colors