Revised Posted April 15, 2008 Share Posted April 15, 2008 Are there any differences between div class and div id? When I use them, they seem to play the exact same roll as far as what they're capable of doing. Quote Link to comment Share on other sites More sharing options...
dennismonsewicz Posted April 15, 2008 Share Posted April 15, 2008 Div class allows you to implement the same style to several html entities VS div id is unique Note: a DIV (or any HTML entity for that matter) can have both an id and a class Quote Link to comment Share on other sites More sharing options...
rhodesa Posted April 15, 2008 Share Posted April 15, 2008 Proper HTML is to use an ID only once on a page, while classes can be used several times. So, classes are for generic styles, like: /* Style for DIVs with Blue backgrounds */ div.blueback { background: blue; } ids are meant to be specific, like: /* Style for the Top Navigation Div */ div.top_nav{ margin: 30px; } Quote Link to comment Share on other sites More sharing options...
Revised Posted April 15, 2008 Author Share Posted April 15, 2008 So if you plan on using multiple html entities with the same div id, you may as well make it easier on yourself and use class instead? Quote Link to comment Share on other sites More sharing options...
dennismonsewicz Posted April 15, 2008 Share Posted April 15, 2008 yes, I typically use classes anyway, but thats just a personal preference Quote Link to comment Share on other sites More sharing options...
Revised Posted April 15, 2008 Author Share Posted April 15, 2008 Same here, I was using class. I suppose I'll stick with my original method after hearing your opinions, rhodesa and dennismonsewicz. Thanks you two! Quote Link to comment Share on other sites More sharing options...
rhodesa Posted April 15, 2008 Share Posted April 15, 2008 So if you plan on using multiple html entities with the same div id, you may as well make it easier on yourself and use class instead? Using IDs over CLASSes is more when you get into JavaScript. But it's pretty easy to differentiate if you just this rule of thumb: ID - Specific, for this element only CLASS - Reusable, happens many times Quote Link to comment Share on other sites More sharing options...
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.