Lesson 5 +10 XP

CSS Comments

Comments are little notes for yourself (or your teammates). The browser ignores them completely.

The syntax

Code

css
/* This is a comment */
p1 {
  color: red; /* this is an inline comment */
}

They start with /* and end with */.

What you can write in comments

  • Explain a default weird rule.
  • Note what a block of CSS does.
  • Group sections:
Code

css
/* -  -  -  -  - Buttons -  -  -  -  - */
.btn { }
/* -  -  -  -  - Cards -  -  -  -  - */
.card { }
  • Temporarily disable a rule while you debug (comment it out without deleting).

Reminder

Comments do NOT show up in your page. Only humans read them.

TL;DR

  • /* ... */ anywhere, multiple lines fine.
  • Use them to explain and debug your CSS.
  • Never break the /* */ pairing.