CSS Comments
A comment is a note in your CSS code. The browser ignores it. Comments help you to explain your code and to remember why you wrote something.
Syntax
A CSS comment starts with /* and ends with */.
/* This is a single-line comment */
h1 {
color: blue; /* a comment after a declaration */
}
/*
This is a
multi-line comment
*/
Comment out code
Put a comment around a rule to switch it off for some time, without deleting it.
p {
color: red;
/* background-color: yellow; */
}
Note:
CSS has no // style comment. Only /* */ works. In most editors the shortcut is Ctrl + /.
Summary
- Write comments between
/*and*/. - They can be on one or many lines.
- Use them for notes and for switching off code.
- Next: CSS Selectors.
Congratulations! Chapter Finished. Learn more about the similar topics:
| Exercises & Assignments |
|---|
| No Content Found. |
| Interview Questions & Answers |
|---|
| No Content Found. |