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.

visual selectors<br />

Seeing selectors visually<br />

Let’s take some selectors and see how they map<br />

to the tree you just created. Here’s how this “h1”<br />

selector maps to the graph:<br />

h1 {<br />

font-family: sans-serif;<br />

}<br />

300 Chapter 8<br />

This selector matches any<br />

elements in the page, and<br />

there’s only one.<br />

And here’s how the “h1, h2” selector looks:<br />

h1, h2 {<br />

font-family: sans-serif;<br />

}<br />

Now the selector<br />

matches both and<br />

elements.<br />

If we use a “p” selector, here’s how that looks:<br />

p {<br />

}<br />

font-family: sans-serif;<br />

This selector matches all the<br />

elements in the tree.<br />

head<br />

html<br />

body<br />

We can only style<br />

elements in the body,<br />

so we’re not showing<br />

the element<br />

and everything under it.<br />

h1 p<br />

p<br />

h2 p<br />

img a em a<br />

html<br />

body<br />

h1 p<br />

p<br />

h2 p<br />

img a em a<br />

html<br />

body<br />

h1 p p<br />

h2<br />

p<br />

img a em a

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

Saved successfully!

Ooh no, something went wrong!