Reputation: 7576
According to the HTML4 spec,
Almost every HTML element may be assigned identifier and class information.
What it doesn't say is which elements can't have an id or class. Which elements can't?
Upvotes: 2
Views: 516
Reputation: 65808
Your question specifically mentions the HTML 4.01 standard. If you look at the bottom of the documentation for id
and class
at MDN, you'll see a table of which specifications these attributes are present in. The table shows:
The current version of HTML is HTML 5.x, which has been standardized for several years now and formally introduced "global attributes". In that standard, global attributes, can be used anywhere according to the documentation and the actual HTML specification, but may not have any impact depending on where you use them:
Global attributes are attributes common to all HTML elements; they can be used on all elements, though the attributes may have no effect on some elements.
For all practical purposes, everything in the body
(including body
) can have an id
and/or a class
, head
can have an id
, but given that there is only one head
in a document (and only one body
for that matter), that is never really needed. Nothing outside of the body would ever need a class
.
Upvotes: 3