Comments explain non-obvious intent in CSS and help teams maintain complex style systems.
Syntax
/* This is a CSS comment */
Good comment examples
- Why a browser workaround exists.
- Why a strange z-index value is required.
- Why an accessibility override must not be removed.
Pitfall
Commenting obvious declarations creates noise. Comment intent, not mechanics.
Important interview questions and answers
- Q: What should CSS comments capture?
A: Constraints and rationale that are not obvious from declarations. - Q: Are comments shipped to users?
A: Usually stripped in minified production bundles. - Q: Why avoid stale comments?
A: Outdated comments mislead future maintainers more than no comment.
Pitfall: Check cascade order—author stylesheet loses to inline styles and !important surprises.