Which HTML tags can use the class attribute?
(In which standards — e.g. HTML/XHTML/HTML5 etc. — and in which browsers.)
For example, is the following legal or not?
<i class="myclass">text inside</i>
Thanks.
In HTML 4, the class attribute can be used in all elements except but BASE, BASEFONT, HEAD, HTML, META, PARAM, SCRIPT, STYLE, and TITLE (see index of attributes in the HTML 4.01 specification). And since XHTML 1.0 is (briefly) just HTML 4 with XML syntax, this does also apply to XHTML 1.0.
In HTML5, the class attribute, along with the accesskey, contenteditable, contextmenu, dir, draggable, hidden, id, lang, spellcheck, style, tabindex and title attributes, is valid on all elements. See http://dev.w3.org/html5/spec/elements.html#global-attributes
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With