Comments are used to explain the code and can help you when you edit the source code at a later date. They are not displayed in the browser and do not affect the execution of your styles.
CSS comments are placed inside the <style> element or the external .css file. They begin with /* and end with */.
/* This is a single-line CSS comment */
p {
color: #2e7d52;
}
You can also create multi-line comments by spanning your text across multiple lines inside the same comment markers.
/*
This is a multi-line CSS comment.
It can span as many lines as you want.
We often use it for documenting complex sections of code.
*/
body {
background-color: #f1f1f1;
}
A very common use of comments is to temporarily "turn off" sections of code during testing or debugging, without deleting it forever.
p {
color: red;
/* font-size: 20px; */ /* This style is currently disabled */
}
/* ====================
BUTTON STYLES
==================== */
.btn-primary {
background-color: blue;
color: white;
}