Ben
Ben

Reputation: 25807

which html tags can use class attribute example: <i class="myclass">text inside</i>?

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.

Upvotes: 2

Views: 3597

Answers (3)

Alohci
Alohci

Reputation: 82976

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

Upvotes: 3

Gumbo
Gumbo

Reputation: 655169

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.

Upvotes: 7

Fidi
Fidi

Reputation: 5834

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.

Upvotes: 1

Related Questions