grabenair Posted August 9, 2012 Report Posted August 9, 2012 (edited) This has been touched on a few times. Sorry, but I am going to again. As a beginner it is easy to get caught making everything a class. This is bad practice. To avoid another real long rant on my part I am going to give you some reading on this subject. I hope this is ok? If not I am sure Andrea will zap me. w3schools has the basic http://www.w3schools.com/css/css_id_class.asp tizg has a good article http://www.tizag.com/cssT/cssid.php css-tricks has a very good article http://css-tricks.com/the-difference-between-id-and-class/ Edited August 9, 2012 by grabenair Quote
benjaminmorgan Posted August 9, 2012 Report Posted August 9, 2012 Most of the time I do just use classes. I will use ID's if it is something I absolutely know is only going to occur once on the page. When I use ID's most is when I use Javascript because I know if it has an ID it must be having something done to it in Javascript. Quote
Andrea Posted August 10, 2012 Report Posted August 10, 2012 Most of the time I do just use classes. I will use ID's if it is something I absolutely know is only going to occur once on the page. . That's how it's supposed to be. I don't know JavaScript, so I cannot comment on what you said about that. Quote
benjaminmorgan Posted August 10, 2012 Report Posted August 10, 2012 I just know the basics of javascript/jquery. Quote
grabenair Posted August 10, 2012 Author Report Posted August 10, 2012 I have wrote a long explanation on use id or class but LSW is a lot better writer then I. So I am going to refer you two to his article. http://www.killersites.com/community/index.php?/topic/75-two-basic-css-mistakes/ Also it must have been ok for me to post the links that I did because Andrea did not zap me, please read. Seance I started web designing four years ago, I know not very long, every tutorial paid or free and books that I have read goes into this. IT is much better practice to us id's over classes. Only use classes if you need to. My intent is not to make Andrea or benjaminmorgan mad, I apologize to you both ahead of time if I have. My intent is to help newbies to writing css to use good practice to start off with because it is hard to change a bad habit. Quote
Andrea Posted August 10, 2012 Report Posted August 10, 2012 My intent is not to make Andrea or benjaminmorgan mad, I apologize to you both ahead of time if I have. My intent is to help newbies to writing css to use good practice to start off with because it is hard to change a bad habit. Helping and providing info is what this is all about. The ID vs. class thing really is simple. If something only happens ONCE per page, use IDs, if more than once or if you're not sure yet, use a class. Things like header, footer, navigation are usually pretty sure bets of only appearing once. HTML5/CSS3 will take care of that issue, since 'header' will be neither id nor class, just <header> Quote
LSW Posted August 10, 2012 Report Posted August 10, 2012 I have wrote a long explanation on use id or class but LSW is a lot better writer then I. So I am going to refer you two to his article. Slimmer! Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.