I know that a class can be repeated but that an id should only be used once, but why is this? If I give several elements the same ID they work just as well as classes. What am I missing here?
Asked
Active
Viewed 403 times
1
-
3"*What am I missing here?*" - Valid HTML, and inevitable JavaScript errors. Please have a look at: [CSS: div id VS. div class](http://stackoverflow.com/questions/544010/css-div-id-vs-div-class)." – David Thomas Apr 30 '14 at 12:27
-
...oh and CSS cascade errors too. – Paulie_D Apr 30 '14 at 12:28
-
That _might_ work, but you have no guarantee for that, since it is not supported, officially. That means: you will run into problems as soon as you use some kind of library which relies on valid html markup. – arkascha Apr 30 '14 at 12:28
1 Answers
0
Not on all browsers and not for all purposes (for example javascript stuff)
There's really no reason why you would want to risk it...

Moshe Shaham
- 15,448
- 22
- 74
- 114