freecoding.school100% FREE · NO SIGNUP
Cascade FallsISSUE #2 of 33

syntax · selector · declaration · property · value

StylaVSThe Specificity Sphinx
Styla saysA CSS rule is a selector plus a block of property:value declarations.

Every rule has the same shape: a selector (what to style) followed by a declaration block in braces. Inside, each declaration is a property: value; pair. h1 { color: red; font-size: 24px; } selects all h1s and sets two properties. Master this anatomy and the whole language opens up.

Power-ups you unlock

The Specificity Sphinx attacks — common mistakes

Boss battleWrite one rule that sets three properties on <p>: color, font-size, and line-height.

Example code

<!doctype html><html><head><meta charset="utf-8">
<style>p { color:#8aff9d; font-size:18px; line-height:1.6; }</style></head><body style="background:#06040d"><p>three declarations, one rule.</p></body></html>
▶ Open the interactive comic issue
‹ Why Css · Separating Style From StructureHow To Add Css · Inline · Internal · External ›