Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Web Technology by (20.3k points)

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

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

<div id="nested_element_123 task_123"></div>

I realize I have an easy solution with simply using a class. I'm just curious about using ids in this manner.

1 Answer

0 votes
by (40.7k points)

If the element has multiple ID attributes, all of them must be treated as IDs for that element for the purposes of the ID selector. It can be done by using mixtures of xml:id, DOM3 Core, XML DTDs, and namespace-specific knowledge.

Note: An XHTML element can have multiple ids, for example: <p id="foo" xml:id="bar"> But for assigning multiple ids to the same id attribute using a space-separated list is not possible.

Related questions

0 votes
1 answer
0 votes
1 answer
asked Sep 9, 2019 in Web Technology by Tech4ever (20.3k points)
0 votes
1 answer
0 votes
1 answer

Browse Categories

...