04.06.2013 Views

Head First HTML with CSS

Head First HTML with CSS

Head First HTML with CSS

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Q: What makes a specificity number<br />

bigger than another?<br />

A: Just read them like real numbers:<br />

100 (one hundred) is bigger than 010 (ten)<br />

which is bigger than 001 (one), and so on.<br />

Q: What about a rule like “h1, h2”;<br />

what is its specificity?<br />

A: Think of that as two separate rules:<br />

an “h1” rule, which has a specificity of “001”<br />

and an “h2” rule that also has a specificity<br />

of “001”.<br />

Putting it all together<br />

there are no<br />

Dumb Questions<br />

Q: Can you say more about the<br />

!important thing?<br />

A: The reader can override a style by<br />

putting an “!important” on the end of their<br />

property declarations like this:<br />

h1 {<br />

font-size: 200%<br />

!important;<br />

}<br />

and this will override any author styles.<br />

Woo hoo! It’s time for an example. Say you want to know the color<br />

property for this element:<br />

Blueberry Bliss Elixir<br />

Let’s take this through all the cascade steps:<br />

Step one:<br />

Gather all your style sheets together.<br />

h1 {<br />

color: #efefef;<br />

}<br />

h1.blueberry {<br />

color: blue;<br />

}<br />

Usually, you’re the author<br />

(the person writing the<br />

<strong>CSS</strong>). But right now,<br />

you’re the browser.<br />

The Author<br />

Remember, you’re<br />

the browser, because<br />

you’re trying to<br />

figure out how to<br />

display this <br />

element.<br />

body h1 {<br />

color: #cccccc;<br />

}<br />

divs and spans<br />

Q: I can’t get the reader’s style sheet,<br />

so how can I ever figure out the way the<br />

cascade works?<br />

A: You can’t, but look at it this way: if<br />

the reader overrides your styles, then that<br />

is really beyond your control. So just make<br />

your pages look like you want them to using<br />

your styles. If the reader chooses to override<br />

them, then they’ll get what they ask for (for<br />

better or for worse).<br />

h1 {<br />

color: black;<br />

}<br />

The Browser<br />

The Reader<br />

That’s you (for now).<br />

The person using the browser.<br />

you are here 477

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!