04.06.2013 Views

Head First HTML with CSS

Head First HTML with CSS

Head First HTML with CSS

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

nesting divs<br />

Exposing even more structure<br />

There are a couple of reasons you might<br />

want to add more structure to your<br />

pages <strong>with</strong> s. <strong>First</strong>, you may<br />

want to further expose the underlying<br />

logical structure of your pages, which<br />

can help others understand them, and<br />

also help in maintaining them. Second,<br />

there are times when you need the<br />

structure so that you have a way to apply<br />

style to a section. Often, you’ll want to<br />

add the structure for both reasons.<br />

So, in the case of PetStorz, we could<br />

take this to the next level and add a few<br />

more s...<br />

Adding structure on structure<br />

436 Chapter 11<br />

Now we’ve added<br />

another <strong>with</strong> an<br />

id indicating this is the<br />

header of the page.<br />

Adding this structure through s<br />

can even help you think through your<br />

page design. For instance, does this<br />

lone really need to be here?<br />

And you don’t have to stop there. It is<br />

common to nest structure, too. For instance,<br />

in the PetStorz page, we have a cat section<br />

and a dog section, and the two together are<br />

logically the “pets” section of the page. So,<br />

we could place both the “cat” and “dog”<br />

s into a “pets” .<br />

And another indicating<br />

the footer of the page.<br />

Now we’ve marked up this X<strong>HTML</strong> so that<br />

we know there is a logical section in the page<br />

<strong>with</strong> “pets” content in it. Further, that “pets”<br />

section has two logical subsections, one for<br />

“cats” and one for “dogs”.<br />

div id=“header”<br />

h1<br />

div id=“cats”<br />

h2<br />

div id=“dogs”<br />

h2<br />

p<br />

p<br />

p<br />

p<br />

div id=“footer”<br />

div id=“header”<br />

p<br />

h1<br />

div id=“pets”<br />

div id=“cats”<br />

p<br />

h2<br />

p<br />

div id=“dogs”<br />

h2<br />

p<br />

div id=“footer”<br />

img<br />

img

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

Saved successfully!

Ooh no, something went wrong!