Comment

Comment by ahoge

>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.

parent ahoge 13 years ago

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton