CSS comments allow us to write notes and explanations in the code. These are ignored by the browser and are only intended for developers.
In CSS, comments are always placed between /* and */. They can be used on a separate line or at the end of a line of code.
In larger projects, comments help in structuring the code, for example marking separate sections or recording important information.
In larger projects, comments are often used to create section headers that help with quick orientation in the code.
When CSS is minified, comments usually disappear. If you want certain comments (such as license information) to remain, use the /*! ... */ syntax.
The most common mistake is when the comment is not closed. In that case, the entire file becomes invalid. Also note that // style comments are not valid in CSS.
Comments can effectively support the readability and maintainability of code. Here are some suggestions:
Please sign in to ask Lara about CSS Comments.
Select Language
Set theme
© 2025 ReadyTools. All rights reserved.