Lesson 5 +10 XP

CSS Comments

CSS Comments

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

The syntax

/* 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:
/* ---------- 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.