Member-only story
CSS Fundamentals: Commenting
A CSS comment is typically used to add additional notes to our code — which are not read by the browser.
We could also use comments to “comment out” a section of code, in order to prevent the browser from interpreting it.
Let’s take a look!
🤓 Want to stay up to date with web dev?
🚀 Want the latest news delivered right to your inbox?
🎉 Join a growing community of designers & developers!
Subscribe to my newsletter here → https://easeout.eo.page
The syntax
We can add a comment like so:
/* This is a comment */
Comments can be used in a single line, or over multiple lines. Until you add the closing */
token, the all the lines between are commented.
For example:
/* A one-line comment */
/*
A
multi-
line
comment
*/
/*
span {
display: block;
color: red;
}
*/
If you have experience with other languages such as JavaScript, you’ll be familiar with inline commenting using //
. CSS doesn’t have inline commenting! So if you add //
before a rule like so:
// Comment here
span {
display: block;
color: red;
}