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

后端 未结 16 1856
无人及你
无人及你 2020-11-21 05:30

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
16条回答
  •  盖世英雄少女心
    2020-11-21 05:54

    Yes they can.

    I don't know if all these anwers are outdated, but just open youtube and inspect the html. Try to inspect the suggested videos, you'll see that they all have the same Id and repeating structure as follows:

    
    

提交回复
热议问题