Posts: 256
Location: Auckland, New Zealand
|
Not the best definition for ID, CSS puts it as a unique identifier for an element, very vague, basically it doesn't mean one time only use, it means it can not be used on another element within the same document. You can use it more than once as long as it's a different document/page/markup whatever, just don't use it twice in the same document.
I usually use IDs to structure a page, since you usually only have 1 header in a page, 1 footer in a page, so an ID being used for these areas makes sense, because they only appear once on that page (well should only appear once)
Not only that, IDs can also be used as bookmarks within a page, meaning you can directly link to those certain areas, e.g. <a href="#footer">Check out my footer</a> will skip to my footer area, which is the location I gave the ID footer.
Classes can be used more than once, usually when you need multiple elements to take on the same styles. Though if you get comfortable with CSS Selector Specific, you can eliminate over using classes.
An example is using it to center text within block elements, you might have many elements that you want to center align the text, so you could have the style .center { text-align: center; } and can put that on multiple elements. When browsers get CSS 2.1 fully supported, you'll be able to add multiple classes to the one class attribute e.g. <div class="firstclass secondclass thirdclass"> and so on, just seperating them by a space.
Cheers,
MC
__________________
#------------------------------ signature---------------------------------------------------------------------------------#
Quote:
|
I am well recognised for what I don't do than what I do. Chores are just one of those things.
|
|