HTML and CSS Reference
In-Depth Information
Step three: Save your changes and reload the page
Q: So why did you make the selector #guarantee rather
than p#guarantee?
A: We could have done either, and they both would select
the same thing. On this page, we know that we will always
have a paragraph assigned to the id, so it doesn't really matter
(and #guarantee is simpler). However, on a more complex set
of pages, you might have some pages where the unique id is
assigned to, say, a paragraph, and on others it's assigned to a
list or block quote. So you might want several rules for the id, like
p#someid, and blockquote#someid, depending on which kind of
element is on the page.
Q: Should I always start with a class, and then change it
to an id when I know it's going to be unique?
A: No. You'll often know when you design your pages if an
element is going to be unique or not. We only did things this way
in the chapter because, well, you didn't know about id when we
started. But don't you think we tied id into the story rather nicely?
Q: What are the rules for class and id names?
A: Class names should begin with a letter, but id names can
start with a number or a letter. Both id and class names can
contain letters and numbers as well as the _ character, but no
spaces. So “number1” works, as does “main_content”, but not
“header content”. Just remember, ids must be unique!
Search WWH ::




Custom Search