can anyone give a good explanation in the difference between an id and a class in CSS I've found that I can really use them interchangeably.. so is there a right time to use one or the other?
A patch is a piece of software which replaces old bugs with new bugs.
West Chatham Homes | Custom American made Caps | Custom Handmade Knives






andy206uk posted this at 00:26 — 26th November 2006.
He has: 1,754 posts
Joined: Jul 2002
Hi,
An ID should always be unique, therefore you should only use them to identify unique parts of the page for instance your header. Each ID should only appear on a page ONCE.
Classes can be used as many times as you like.
At least... that's how I understand it...
Andyk
Blog of a Web Designer
Give a man a fish and you feed him for a day. Teach him to use the Net and he won't bother you for weeks.
Roo posted this at 19:26 — 26th November 2006.
She has: 836 posts
Joined: Apr 1999
Yes, that about sums it up
. I've never tried it, but if you were to try to use an ID more than once I don't think it would even display more than once. Am I right or wrong about that?
Roo
Blog • Photolog • Galleries • KidsWeb • Baby Picasso • Web Design
andy206uk posted this at 19:53 — 26th November 2006.
He has: 1,754 posts
Joined: Jul 2002
That's how it should work, but in my experience most browsers just treat it like a class and repeat the styling. The HTML validator growls at you if you do use them more than once though...
Andyk
Blog of a Web Designer
Give a man a fish and you feed him for a day. Teach him to use the Net and he won't bother you for weeks.
Megan posted this at 14:09 — 27th November 2006.
She has: 10,304 posts
Joined: Jun 1999
The browsers have no problem with duplicate ID's. The validator does.
Think of Classes and ID's this way: a class is a group. Anyone can belong. An ID is an identification number - it has to be unique to one individual.
Megan
My web design blog
blackhawkpowers posted this at 23:32 — 27th November 2006.
They have: 38 posts
Joined: Nov 2006
alright thanks for the help guys