Hi,
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.
Hi,
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.
Well I am pretty sure, that each and every tag may contain the class-attribute (correct me, if I am wrong).
EDIT
Okay Gumbo stated the tags, that a not allowed to use the class-attribute for good reason (see my comment at his answer). Thank you.
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.
I would suggest using <em>text inside</em>
rather than <i>
as it is more semantically correct.
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