W22

WEEK 22

Writing CSS Rules
web.selah-hcs.orgweb design for kids // html5 + css3one day academy
THIS WEEK'S JOB // Learn the grammar cold: selectors, braces, colons, semicolons, no mercy for typos. (Book pages 171-177 in Mrs. Gaiser's book.)

THE THREE IDEAS

Punctuation is law
Braces around the block, colon after the property, semicolon after the value. One missing semicolon and every rule after it sulks silently.
Selectors can be picky
Element selectors hit every tag of a kind. Classes (.special) hit only the elements you badge. ids (#header) hit exactly one.
The cascade
When rules disagree, the more specific one wins, and ties go to whoever spoke last. That is the C in CSS and the answer to why did my rule not work.

TRY IT IN THE PAINT BOOTH

<style>
  p { color: #444; }
  .warning { color: #e33b2f; font-weight: bold; }
</style>
<p>A normal paragraph.</p>
<p class="warning">This one is badged with a class.</p>
OPEN THE PAINT BOOTH, PRELOADED »

ON YOUR LOT

Add one class to your stylesheet and badge two elements with it. Then break a semicolon on purpose and watch what stops working; now you know the crash you will hunt all year.
« W21W23 »