div id Vs. div class |
For a list of all requirements and guidelines pertaining to posting a new Help topic, please click here.
This Month's Contests | Staff Member of the Month | Hosts Looking for Hostees | Hostees looking for Hosts | BigBookofResources
Submission Guidelines
![]() ![]() |
div id Vs. div class |
![]()
Post
#1
|
|
![]() Sex, Blood, & RocknRoll ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: People Staff Posts: 5,305 Joined: Nov 2007 Member No: 596,480 ![]() |
When is it proper to use a id verses a class? and the other way around?
It's been ages since I have looked at any kind of code so help a n00b out? |
|
|
![]()
Post
#2
|
|
![]() Senior Member ![]() ![]() ![]() ![]() ![]() ![]() Group: Administrator Posts: 2,648 Joined: Apr 2008 Member No: 639,265 ![]() |
IDs are supposed to be unique per-page. You use an ID to describe a unique element on the page; you use a class to describe items that are generic and non-unique.
Take the front page of a blog, for example: the header would probably be div#header, whereas each blog post may be encapsulated as the div.blog-post class, since there are several of them and it's a generic container. |
|
|
![]()
Post
#3
|
|
![]() /人◕‿‿◕人\ ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: Official Member Posts: 8,283 Joined: Dec 2007 Member No: 602,927 ![]() |
I had no idea that there was actually a proper time to use an ID vs a class.
|
|
|
![]() ![]() |