Attributes in HTML

A list and explanation of HTML attributes.

1598 views

Edited: 2016-10-04 17:56

HTML attributes can be used to better control and access elements, allowing to easier target specific elements with CSS declarations, and to access elements through scripting.

Attributes are added to the opening tag of HTML elements. Unless specified otherwise, attribute values themselves should generally be enclosed in either double quotes (") or single quotes (').

If an attribute value contains double quotes, then you can use single quotes around the attribute value instead.

Global Attributes

Attributes are added in the opening tag of HTML elements, beginning with the name of the attribute, followed by the equal sign (=) and finally its quoted value. I.e.: (Name="attribute value")

Attribute:Description:
styleUsed to apply styles.
titleUsed for tool-tips.
classUsed to "group" elements. See also: CSS selectors
idUnique id_name.
accesskey Creates a keyboard shortcut that will focus on the element when pressed.
contenteditable Makes the content of the element editable.
contextmenu
dir
draggable
dropzone
hidden The element is hidden. Similar to display:hidden;
is
itemid
itemprop
itemref
itemscope
itemtype
lang Defines the language of the element and it's children.
spellcheck Enables spellcheck of the element.
tabindex
translate

Event Attributes

The event attributes is used by scripts.

Attribute:Value:Description:
onclickScriptA pointer button was clicked.
ondblclickScriptA pointer button was double clicked
onmousedownScriptA pointer button was pressed down
onmouseupScriptA pointer button was released.
onmouseoverScriptA pointer was moved onto.
onmousemoveScriptA pointer was moved within.
onmouseoutScriptA pointer was moved away.
onkeypressScriptA key was pressed and released.
onkeydownScriptA key was pressed down.
onkeyupScriptA key was released.
onloadScriptWhen either the page (use on body), image, or frame loads.

I18n Attributes

The Internationalization Attributes.

Attribute:Value:Description:
langLanguageCodeLanguage code
dirltr|rtlDirection for text.

Tell us what you think: