What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Skype & Technology » Tech Talk » CSS - id vs class

CSS - id vs class
Author: Message:
stoshrocket
Senior Member
****

Avatar
formerly methos

Posts: 748
Reputation: 31
34 / Male / Flag
Joined: Aug 2005
O.P. CSS - id vs class
Something I never really looked too deeply into, all I know that an id and class use different predeceeding symbols in the style sheet (eg #id_name and .class_name), but what's the actual difference and where would you use one over the other? When I first started to use CSS I just used id because it's shorter and easier to type, and so I rarely use class, but for no real reason...
formerly methos
06-08-2009 06:23 PM
Profile PM Web Find Quote Report
Eljay
Elite Member
*****

Avatar
:O

Posts: 2949
Reputation: 77
– / Male / –
Joined: May 2004
RE: CSS - id vs class
http://lmgtfy.com/?q=CSS+-+id+vs+class
06-08-2009 06:26 PM
Profile PM Find Quote Report
gif83
Full Member
***

Avatar

Posts: 317
Reputation: 25
41 / Male / Flag
Joined: Jan 2005
RE: CSS - id vs class
As far as I know classes are for things that turn up time and time again so you can have different things with the same class.
IDs are for individual things as it's used as some sort of identifier for that particular thing.


EDIT:
Yeah, go read Matti's post, it's far more eloquently put.

This post was edited on 06-08-2009 at 06:44 PM by gif83.
06-08-2009 06:31 PM
Profile E-Mail PM Web Find Quote Report
Matti
Elite Member
*****

Avatar
Script Developer and Helper

Posts: 1646
Reputation: 39
32 / Male / Flag
Joined: Apr 2004
RE: CSS - id vs class
IDs have to be unique, there can only be one element in the document tree with a certain ID. Classes can be used multiple times throughout the tree and you can apply any amount of classes on one element.

In practice, you'd use IDs for unique things in your layout such as #page-container, #header, #content, #sidebar and #footer whereas classes can be used for things which are used more than once like .post, .comment, .alignright, .smallicon etc. At least, that's how I use them. :P
Plus! Script Developer | Plus! Beta Tester | Creator of Countdown Live | Co-developer of Screenshot Sender 5

Found my post useful? Rate me!
06-08-2009 06:40 PM
Profile E-Mail PM Web Find Quote Report
stoshrocket
Senior Member
****

Avatar
formerly methos

Posts: 748
Reputation: 31
34 / Male / Flag
Joined: Aug 2005
O.P. RE: CSS - id vs class
Yeah, cool... Good to know, although to be honest I've never seen an instance where using id for multiple objects on a page caused a problem, the only reason I can see is for validation purposes...

Thanks for the info anyways! :happy:
formerly methos
06-08-2009 07:46 PM
Profile PM Web Find Quote Report
NanaFreak
Scripting Contest Winner
*****


Posts: 1476
Reputation: 53
32 / Male / Flag
Joined: Jul 2006
RE: CSS - id vs class
ids are used more in javascript, because they are meant to be only used once...
06-08-2009 08:50 PM
Profile PM Find Quote Report
« Next Oldest Return to Top Next Newest »


Threaded Mode | Linear Mode
View a Printable Version
Send this Thread to a Friend
Subscribe | Add to Favorites
Rate This Thread:

Forum Jump:

Forum Rules:
You cannot post new threads
You cannot post replies
You cannot post attachments
You can edit your posts
HTML is Off
myCode is On
Smilies are On
[img] Code is On