Chapter 4

Making CSS Make Sense

IN THIS CHAPTER

Bullet Making CSS more readable with comments

Bullet Making CSS behave with a reset

Bullet Making CSS do what it’s supposed to do by debugging your code

Bullet Making CSS comprehensible by understanding how it applies its rules

CSS is hard because its properties interact, often in unexpected ways. Because when you set one of them, you’re never just setting that one thing. That one thing combines and bounces off and contradicts a dozen other things, including default things that you never actually set yourself.

—BRANDON SMITH

CSS is one of those simple-on-the-outside, complex-on-the-inside things. Basic CSS is nothing but a collection of rules, each of which is a set of properties and their values, all applied to a specified selector. At this level, CSS seems almost trivial or, at the very most, resolutely straightforward. Ah, but untold legions of promising CSS careers have foundered on this Rock of Simplicity. Cocky JavaScript programmers routinely wash their hands of CSS with the lament, “This looks right, so why doesn’t it work?”

It probably doesn’t work because ...

Get HTML, CSS, & JavaScript All-in-One For Dummies now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.