Attributes in HTML
A list and explanation of HTML attributes.
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: |
style | Used to apply styles. |
title | Used for tool-tips. |
class | Used to "group" elements. See also: CSS selectors |
id | Unique 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: |
onclick | Script | A pointer button was clicked. |
ondblclick | Script | A pointer button was double clicked |
onmousedown | Script | A pointer button was pressed down |
onmouseup | Script | A pointer button was released. |
onmouseover | Script | A pointer was moved onto. |
onmousemove | Script | A pointer was moved within. |
onmouseout | Script | A pointer was moved away. |
onkeypress | Script | A key was pressed and released. |
onkeydown | Script | A key was pressed down. |
onkeyup | Script | A key was released. |
onload | Script | When either the page (use on body), image, or frame loads. |
I18n Attributes
The Internationalization Attributes.
Attribute: | Value: | Description: |
lang | LanguageCode | Language code |
dir | ltr|rtl | Direction for text. |
Tell us what you think: