HTML Global attributes - 12 Attributes (Reference)

Tech:
Html
Since:
1 year ago
Views:
9

In HTML, global attributes are attributes that are not associated with any specific element. It is possible to use global attributes in any HTML element.

class

Specifies one or more classnames for an element and can be used to style elements using CSS.

<span class="class_name"></span>

id

Specifies a unique id for an element.

<span id="id_name"></span>

style

Specifies an inline CSS style for an element.

<p style="color:green;">Some text</p>

title

Specifies extra information about an element. Basically a tooltip text.

<p title="Some text">Some text</p>

lang

Specifies the language of the element's content.

<p lang="en">Some text</p>

contenteditable

Specifies whether the content of an element is editable or not.

<p contenteditable="true">Some text</p>

<p contenteditable="false">Some text</p>

hidden

Specifies that an element is not yet, or is no longer, relevant.

<p hidden>Some text</p>

accesskey

Specifies a shortcut key to activate/focus an element. Single character only.

<input accesskey="a" />

data-*

Used to store custom data private to the page or application. Lowercase letters only.

<span data-custom-attr="some_class"></span>

dir

Specifies the text direction for the content in an element.

<p dir="ltr">Some text</p>

<p dir="rtl">Some text</p>

<p dir="auto">Some text</p>

draggable

Specifies whether an element is draggable or not.

<p draggable="true">Some text</p>

<p draggable="false">Some text</p>

<p draggable="auto">Some text</p>

spellcheck

Specifies whether the element is to have its spelling and grammar checked or not.

<input type="text" spellcheck="true" />

<input type="text" spellcheck="false" />

tabindex

Specifies the tabbing order of an element. Basically tab button focus order.

<div tabindex="1">Some content</div>
<div tabindex="3">Some content</div>
<div tabindex="2">Some content</div>