Tutorial 17 of 44 in series
CSS Comments
Document your CSS with comments
Abhishek Sharma 2026-05-30 Web Development / Frontend / CSS
Comments
CSS comments are ignored by the browser and help document your code:
Demo: CSS Comments
HTML
<p class="commented">Comments are visible in source but not in rendering</p> CSS
/* This is a single-line comment */
/*
This is a
multi-line comment
*/
.commented {
color: #6366f1; /* inline comment */
font-size: 1.25rem;
}
Live Output Window
CSS vs HTML Comments
| Language | Comment Syntax |
|---|---|
| CSS | /* comment */ |
| HTML | <!-- comment --> |
| JavaScript | // comment or /* comment */ |
Best Practices
/* ================
Layout Sections
================ */
/* Header */
.header { ... }
/* Navigation */
.nav { ... }
/* Footer */
.footer { ... }
Use comments to organize large stylesheets into logical sections - they make maintenance much easier.
Keep learning
Related tutorials from across the library.
Tutorial
Introduction to CSS
Learn what CSS is and why it matters
Web Development / Frontend / CSS
CSSWeb Development
Tutorial
History of CSS
Understand how CSS evolved
Web Development / Frontend / CSS
CSSWeb Development
Tutorial
Adding CSS
Three ways to add CSS to a page
Web Development / Frontend / CSS
CSSWeb Development