In HTML 4 and XHTML 1, you can’t assign a class to the <head> element. However, in XHTML 1.0 you can give it an ID. In HTML5 it seems you can give it a class. I am curious, why you would want to?
In HTML 4 and XHTML 1, you can’t assign a class to the <head>
Share
classis one of what are now called global attributes (along with global events). They’ll have to apply to every single element in the DOM, regardless of its nature.I believe it’s related to the API. The spec defines every DOM HTML element to inherit from a base interface called
HTMLElementthat defines the aforementioned global attributes and events. Namely:With that said, the editor(s) of the spec did make the following note at the end of the list of global attributes/events:
So I suppose they don’t expect you to, but they can neither think of a reason to allow it or not to allow it. It’s just part of the API (i.e. an
HTMLHeadElementis anHTMLElementanyway).