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?
<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.
classes are specially made for this, here is the code from which you can understand
My understanding has always been:
ID's are single use and are only applied to one element...
Classes can be used more than once...
Nay.
https://www.w3.org/TR/2011/WD-html5-20110525/elements.html#the-id-attribute
id="a b"
<-- find the space character in that VaLuE.That said, you can style multiple IDs. But if you're following spec, the answer is no.
No. While the definition from w3c for HTML 4 doesn't seem to explicitly cover your question, the definition of the name and id attribute says no spaces in the identifier:
You can only have one ID per element, but you can indeed have more than one class. But don't have multiple class attributes, put multiple class values into one attribute.
is perfectly legal.