Comments and Organization
CSS comments are ignored by the browser but are valuable for documenting complex sections, design decisions, browser workarounds, or architecture boundaries.
Good comments explain why unusual code exists rather than restating obvious declarations.
CSS Comments Are Ignored
CSS Comments
/* Layout container */
.container {
width: min(100% - 2rem, 1200px);
margin-inline: auto;
}
/* Keep this fallback for older embedded browsers. */
.card {
margin-left: auto;
margin-right: auto;
}💡 Comments can document intent and compatibility decisions without affecting rendering.
Key Takeaways
- CSS comments use
/* */syntax. - Prefer comments that explain intent rather than obvious code.
Knowledge Check
Which syntax creates a CSS comment?