First of all I alwyas use one #ID. just asking this question to know deep reason behind it.
Is it only a matter of W3C validation? or more than that
The result is undefined.
Apart from what the rest said about getElementById
:
#foo
in CSS may apply to all elements with id="foo"
, or to the first, or to the last, depending on how the browser is implemented.page.html#foo
in a URL may scroll to one of the elements, or to the other, or to neither.edit: either way, you should teach your students to do things right even if doing it wrong doesn't seem to have any immediate bad consequences... ;)