Can multiple different HTML elements have the same ID if they're different elements?

omninonsense picture omninonsense · Apr 10, 2011 · Viewed 214.6k times · Source

Can multiple HTML elements have the same ID if they're of different element types? Is a scenario like this valid? Eg:

div#foo
span#foo
a#foo

Answer

SLaks picture SLaks · Apr 10, 2011

No.

Element IDs should be unique within the entire document.