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.

Step Three: save your changes and reload the page.<br />

Well, everything should look<br />

EXACTLY the same. But, don’t<br />

you feel much better now that<br />

everything is as it should be?<br />

Q: So why did you make the selector #guarantee rather<br />

than p#guarantee?<br />

A: We could have done either and they both would select<br />

the same thing. On this page we know that we will always have<br />

a paragraph assigned to the id, so it doesn’t really matter (and<br />

#guarantee is simpler). However, on a more complex set of pages<br />

you might have some pages where the unique id is assigned to,<br />

say, a paragraph, and on others it’s assigned to a list or block<br />

quote. So you might want several rules for the id, like p#someid,<br />

and blockquote#someid, depending on which kind of element is on<br />

the page.<br />

Q: Should I always start <strong>with</strong> a class, and then change it<br />

to an id when I know it’s going to be unique?<br />

there are no<br />

Dumb Questions<br />

the box model<br />

A: No. You’ll often know when you design your pages if an<br />

element is going to be unique or not. We only did things this way<br />

in the chapter because, well, you didn’t know about id when we<br />

started. But don’t you think we tied id into the story rather nicely?<br />

Q: In Chapter 4 we used the id attribute <strong>with</strong> the <br />

element to create a destination anchor. When I put an id on<br />

other types of elements, do they become destinations too?<br />

A: That’s the idea, and most modern browsers support this,<br />

but older browsers don’t.<br />

you are here 419

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

Saved successfully!

Ooh no, something went wrong!