Reputation: 1754
Is class a legal attribute of the HTML element?
<html class="...">
My Oracle ADF application does this — why?
Upvotes: 24
Views: 17347
Reputation: 943567
It is not valid in HTML 4:
<!ENTITY % html.content "HEAD, BODY">
<!ELEMENT HTML O O (%html.content;) -- document root element -->
<!ATTLIST HTML
%i18n; -- lang, dir --
>
It is not valid in XHTML 1.0:
<!ELEMENT html (head, body)>
<!ATTLIST html
%i18n;
id ID #IMPLIED
xmlns %URI; #FIXED 'http://www.w3.org/1999/xhtml'
>
It is valid in HTML 5:
The following attributes are common to and may be specified on all HTML elements (even those not defined in this specification):
- ...
- class
- ...
My Oracle ADF application does this - wounder why
Presumably to apply style or JS from a shared external file to specific pages.
Upvotes: 31
Reputation: 40038
There are some great reasons to use a class on the HTML tag.
You can use such css globals to style around different pages, different browsers, etc.
modernizr uses this technique
css_browser_selector.js uses this technique
Richard Pianka discusses how the technique is used in the above css_browser_selector script
Chris Coyier discusses why the technique is useful
Further Reading:
Avoid setting a global class for html
Upvotes: 8
Reputation: 68790
"The class attribute is not valid in: base, head, html, meta, param, script, style, and title". http://www.w3schools.com/tags/att_standard_class.asp
You can get what you want using this pattern :
<html>
<body class="">
</body>
</html>
or (better, I guess)
<html>
<body>
<div class="">
</div>
</body>
</html>
Upvotes: -2