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.

? brain<br />

power<br />

On a referral from the Starbuzz<br />

CEO, you’ve been asked to<br />

come in and consult on style<br />

changes to PetStorz main<br />

page. How quickly would you<br />

understand the PetStorz Web<br />

page if you were shown Page<br />

One?<br />

What about Page Two?<br />

Adding some style<br />

Okay, so you’ve added some logical<br />

structure to the PetStorz page, and you’ve<br />

also labeled that structure by giving each<br />

a unique id. That’s all you need<br />

to start styling the group of elements<br />

contained in the .<br />

Here we have two rules, one<br />

for each . Each is<br />

selected by an id selector.<br />

#cats {<br />

background-image: url(leopard.jpg);<br />

}<br />

#dogs {<br />

background-image: url(mutt.jpg);<br />

}<br />

Page One<br />

p<br />

h1<br />

h2<br />

p<br />

h2<br />

p<br />

p<br />

img<br />

Now the s<br />

have a little style.<br />

By setting the<br />

background on the<br />

, it also shows<br />

through the elements<br />

contained in the .<br />

The elements in the will also<br />

inherit some properties from the<br />

, just as any child element<br />

does (like font-size, color, etc).<br />

Each rule sets the<br />

background-image<br />

property. For cats we<br />

have a leopard image,<br />

and for dogs we have<br />

a mutt image.<br />

p<br />

Page Two<br />

h1<br />

div id=“cats”<br />

p<br />

h2<br />

p<br />

div id=“dogs”<br />

p<br />

h2<br />

p<br />

h1<br />

div id=“cats”<br />

p<br />

h2<br />

p<br />

h2<br />

p<br />

divs and spans<br />

img<br />

div id=“dogs”<br />

img<br />

you are here 435

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

Saved successfully!

Ooh no, something went wrong!