Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

html

xhtml

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.

like image 608
Ben Avatar asked Mar 21 '26 19:03

Ben


2 Answers

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.

like image 64
Gumbo Avatar answered Mar 23 '26 09:03

Gumbo


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

like image 32
Alohci Avatar answered Mar 23 '26 08:03

Alohci



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!