CSS Comments
CSS comments are notes or messages added to CSS code that the browser ignores. They are helpful for:
- Explaining code
- Making notes for developers
- Marking sections in stylesheets
- Temporarily disabling code during testing
/* This is a comment */
- CSS comments start with /* and end with */.
- They can span single-line or multi-line.
- Comments cannot be nested inside other comments.
Example: Single-Line Comment
/* This is a single-line comment */ h1 { color: red; }
Example: Multi-Line Comment
/* This CSS block styles the main heading and paragraph */ h1 { color: navy; text-align: center; } p { font-size: 18px; color: gray; }
Best Practices
Use comments to label sections like:
/* ======================== Header Styles ======================== */
- Comment complicated rules to improve readability for others (or yourself in the future).
- Use comments to disable code during testing.
Quickly Find What You Are Looking For
OnlineTpoint is a website that is meant to offer basic knowledge, practice and learning materials. Though all the examples have been tested and verified, we cannot ensure the correctness or completeness of all the information on our website. All contents published on this website are subject to copyright and are owned by OnlineTpoint. By using this website, you agree that you have read and understood our Terms of Use, Cookie Policy and Privacy Policy.