- Jan 2, 2006
- 10,455
- 35
- 91
I'm just trying to talk this through to myself. Can someone critique?
So a div ID is for assigning properties to a specific object, but a class is for assigning properties to multiple objects.
If I have sections of a website, say, the header, the footer, and the contents, and I want to apply unique properties to each, I would assign each an ID, correct?
If I've got 15 images, and I want the same properties for each (same padding, border, etc) I should assign the same class to each of those images, correct?
But this is where I get confused and fail to understand why it matters.
Say that I've got a footer ID with XYZ characteristics. I apply this footer ID to the footer section. But I think, hey, I want the same XYZ characteristics for the header section as well. So I just apply the footer ID to the header section. I mean, is there anything stopping me from using ID twice in the same document?
On the flip side, say I've got a Class with XYZ specs. And I only have one image on my page to apply these specs to. So I just use Class once on one object on the entire page.
So it seems that ID and Class both do the exact same thing... right? And now I'm wondering... why have two things that are completely the same except for in name?
So a div ID is for assigning properties to a specific object, but a class is for assigning properties to multiple objects.
If I have sections of a website, say, the header, the footer, and the contents, and I want to apply unique properties to each, I would assign each an ID, correct?
If I've got 15 images, and I want the same properties for each (same padding, border, etc) I should assign the same class to each of those images, correct?
But this is where I get confused and fail to understand why it matters.
Say that I've got a footer ID with XYZ characteristics. I apply this footer ID to the footer section. But I think, hey, I want the same XYZ characteristics for the header section as well. So I just apply the footer ID to the header section. I mean, is there anything stopping me from using ID twice in the same document?
On the flip side, say I've got a Class with XYZ specs. And I only have one image on my page to apply these specs to. So I just use Class once on one object on the entire page.
So it seems that ID and Class both do the exact same thing... right? And now I'm wondering... why have two things that are completely the same except for in name?