CLASS or ID?

cursedpsp

New Member
Messages
237
Reaction score
0
Points
0
I dont know which to use - the professionals use ID's but i dont like using them cause you can't use them more than once. But I don't really see whats so bad about CLASSes, I saw a website a few days ago telling people that they shouldn't use classes because it is beginnerish and it isn't very reliable.

I don't know, what's the difference and what the hell should i use??
 

marshian

New Member
Messages
526
Reaction score
9
Points
0
As far as I know, using an id to determine what layout an object should have is previlleged over the object's class (if your class sets color black and id sets color white, it will be white i think), which could make id's more relieable, but considder the fact you usually have more then one object with the same class, so you'ld have to use the same code for different id's, which is a waste of space...
 

sybregunne

Member
Messages
54
Reaction score
0
Points
6
is that really true that id's cannot be used more than once?

I seem to get away with it. And it works fine. Though the problem there for me is if I used javascript:document.getElementById('idname') then it would return an error. But if used for css purposes only then I think it is okay to use ID.

Another thought is that it can be very helpful if you use classes as a base and id's to augment. as id's tend to have more priority than classes.
 

xeross

New Member
Messages
26
Reaction score
0
Points
0
i use id's for javascript and classes for css, and if u study css a little using id's or classes doesnt really make a differnce in size of the file and stuff
 

VPmase

New Member
Messages
914
Reaction score
1
Points
0
I use id's for AJAX and Javascript, but I also mix them with CSS. Classes are nice for mass styling but for one thing I like to use id's.
 

callumacrae

not alex mac
Community Support
Messages
5,257
Reaction score
97
Points
48
is that really true that id's cannot be used more than once?

Yes.

If you use an id more than once, your site will not be XHTML strict, and you won't be able to use JavaScript.

I use class for css and id for javascript
 
Top