I understand that IDs are supposed to be unique in HTML documents. But a lot of HTML pages are sloppy and don't follow the rule. My question is: how do browsers handle CSS applications for multiple elements sharing the same id?
On my preliminary testing it seems that they apply the id specific CSS rule to all elements with the same id. This behavior seems to be common on IE 8, Chrome, Firefox, Opera.
Is this the sensible choice that browsers make to handle such sloppy HTML or are there exceptions to this behavior? What can be unintended consequences in CSS layout due to sharing of same id amongst multiple elements?
See Question&Answers more detail:os