Assigning a class attribute to an <head> element in HTML5

In HTML 4 and XHTML 1, you cannot assign a class to an element <head>. However, in XHTML 1.0 you can give it an ID. In HTML5, it seems like you can give it a class. I'm curious why would you like to?

+5
source share
1 answer

classis one of what is now called global attributes (along with global events). They will need to be applied to every element in the DOM, regardless of its nature.

, API. HTML DOM HTMLElement, . :

interface HTMLElement : Element {

  // ...

  // metadata attributes
           attribute DOMString id;
           attribute DOMString title;
           attribute DOMString lang;
           attribute DOMString dir;
           attribute DOMString className;
  readonly attribute DOMTokenList classList;
  readonly attribute DOMStringMap dataset;

, /:

. , . , - volumechange , .

, , , , . API (.. HTMLHeadElement a HTMLElement ).

+5
source

All Articles