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.

Isn’t it about time we talk about the “cascade”?<br />

Well, well, we’re quite far into this book (473 pages to be exact) and we still haven’t<br />

told you what the “Cascade” in Cascading Style Sheets is all about. Truth be told,<br />

you have to know a lot about <strong>CSS</strong> to fully understand the cascade. But guess what,<br />

you’re almost there, so wait no more.<br />

Here’s just one last piece of information you need to understand the cascade. You<br />

already know about using multiple style sheets to either better organize your styles<br />

or to support different types of devices. But there are actually some other style sheets<br />

hanging around when your users visit your pages. Let’s take a look:<br />

The Author<br />

(that’s you!)<br />

When the browser needs to determine<br />

which style to apply to an element, it uses<br />

all these style sheets. Priority is given first<br />

to the author’s styles (that is, your styles),<br />

then to the reader’s styles, and then<br />

finally to the browser’s default styles.<br />

<strong>First</strong>, there are all<br />

the style sheets you’ve<br />

written for your page.<br />

The Reader<br />

(your users)<br />

But some browsers also allow users<br />

to create their own styles for<br />

X<strong>HTML</strong> elements. If your style<br />

sheet doesn’t define these styles,<br />

the user’s style sheet is used instead.<br />

The Browser<br />

divs and spans<br />

Note that there is a way for a reader<br />

to actually override your styles. To do<br />

that they put “!important” at the end<br />

of a property declaration.<br />

And finally, you already<br />

know that the browser<br />

itself maintains a set of<br />

default styles that are<br />

used if you don’t define<br />

the styles for an element.<br />

These are also the styles<br />

that are used if you don’t<br />

have any author or reader<br />

style sheets.<br />

you are here 473

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

Saved successfully!

Ooh no, something went wrong!