|
|
|
|
|
by ahoge
4631 days ago
|
|
>The fact that [IDs] cannot be reused in a single page is what makes IDs so useful. This isn't enforced by browsers. They will happily render all elements with the same ID and apply the same styles to all of them. This kind of thing really isn't useful. If you accidentally put the logo twice on the page, it will be clearly visible. It virtually never happens and when it does it isn't hard to track down. This "just once" property of IDs really doesn't add anything useful. >Unlike a class, an ID informs me with 100% certainty that if modified, it will not affect other instances on the page, because there are none. If I modify one of my building blocks, I know that every instance of it will now look like this. Consistency is awesome. |
|
We live in post-xhtml times, browsers will try to make sense and render all sorts of bad code.
>If you accidentally put the logo twice on the page, it will be clearly visible. It virtually never happens and when it does it isn't hard to track down.
You're assuming the visual difference in applied style is always clearly visible, like a repeated logo. No, it's often not, not until someone changes something in a class and the change is populated everywhere the class was reused. An ID is a guarantee it was not reused, or at the very least serves as a "do not reuse" sign.
Edit: formatting