开发者

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>

Than开发者_运维问答ks.


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


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜