Can an html element have multiple ids?

前端 未结 18 2642
天命终不由人
天命终不由人 2020-11-22 07:40

I understand that an id must be unique within an HTML/XHTML page.

My question is, for a given element, can I assign multiple ids to it?

18条回答
  •  无人共我
    2020-11-22 08:08

    No.

    Having said that, there's nothing to stop you doing it. But you'll get inconsistent behaviour with the various browsers. Don't do it. 1 ID per element.

    If you want multiple assignations to an element use classes (separated by a space).

提交回复
热议问题