View video tutorial
HTML Global Attributes
HTML
Global Attributes are applicable to all HTML elements.
HTML Global Attributes
Global Attributes are common to all HTML elements.
The global attributes are supported by both standard and non-standard elements.
Global attributes can be used on all elements, although some elements may have no effect on them.
Element Global Attributes
Attribute | Value | Description |
---|---|---|
accesskey | shortcut key | Specifies a keyboard shortcut to activate or focus the element. |
class | classname | Assigns a class name or space-separated list of class names to an element.It is mainly used with CSS. |
contenteditable | true false |
Indicates whether the content of an element is editable or not by the user. |
contextmenu | menu-id | Specifies a context menu for an element. A context menu is a menu that appears when the user right clicks on the element. |
data-* | data | It is used to store element-specific private data which can be accessed by Javascript. |
dir | rtl ltr auto |
It specifies the direction of the content inside the current element. |
draggable | true false auto |
It specifies whether the content within an element is movable or not using Drag and Drop API. |
dropzone | copy move link |
It specifies the action is taken on the dragged element when it is dropped, ¬¬ such as whether it is copied, moved or linked. |
hidden | It hides the element from the view. | |
id | id | It specifies a unique id for the element. |
lang | language_code | Specifies the primary language for the element's text content. |
spellcheck | true false |
It specifies whether the content should be checked for spelling errors or not. |
style | style | It is used to apply inline CSS to the elements. |
tabindex | number | It specifies the tabbing order of an element. |
title | text | It is used to provide the title, name, or some extra information about the element. |
translate | yes no |
It specifies whether the text content of an element should be translated or not. |
Global Event Handler Attributes
Attribute | Event | Description |
---|---|---|
onabort | abort | Fires when abort. |
onautocomplete | autocomplete | The autocomplete feature specifies whether autocomplete should be turned on or off in a form or input field. |
onautocompleteerror | autocompleteerror | Fires when autocompleteerror occur. |
onblur | blur | Fires when element loses focus. |
oncancel | cancel | The oncancel property is used for processing cancel events sent to a <dialog> element. |
oncanplay | canplay | Fires when a file is ready to start playing. |
oncanplaythrough | canplaythrough | Fires when a file can be played all the way to the end without pausing for buffering. |
onchange | change | Fires when the value of the element is changed. |
onclick | click | Fires when a mouse click on the element. |
onclose | close | The onclose property is used for processing close events sent to a <dialog> element. |
oncontextmenu | contextmenu | Fires when a context menu is triggered. |
oncuechange | cuechange | Fires when the cue changes in a element. |
ondblclick | dblclick | Fires when a mouse double-click on the element. |
ondrag | drag | When a draggable item (element or text selection) is dragged. |
ondragend | dragend | When a drag operation ends (such as releasing a mouse button). |
ondragenter | dragenter | When a dragged item enters a valid drop target. |
ondragleave | dragleave | When a dragged item leaves a valid drop target. |
ondragover | dragover | When a dragged item is being dragged over a valid drop target, every few hundred milliseconds. |
ondragstart | dragstart | When the user starts dragging an item. |
ondrop | drop | When an item is dropped on a valid drop target. |
ondurationchange | durationchange | Fires when the length of the media changes. |
onemptied | emptied | Fires when something happens bad and the file is suddenly unavailable. |
onended | ended | Fire when the media has reached its last stage. |
onerror | error | Fires when an error occurs. |
onfocus | focus | Fires when the element gets focus. |
oninput | input | Fires when an element gets user input. |
oninvalid | invalid | Fires when an element is invalid. |
onkeydown | keydown | Fires when a user presses a key and hold. |
onkeypress | keypress | Fires when a user presses a key. |
onkeyup | keyup | Fires when a user releases a key. |
onload | load | Fires after the page is finished loading. |
onloadeddata | loadeddata | Fires when media data is loaded. |
onloadedmetadata | loadedmetadata | Fires when meta data are loaded. |
onloadstart | loadstart | Fires just as the file begins to load before anything is actually loaded. |
onmousedown | mousedown | Fires when a mouse button is pressed down on an element. |
onmouseenter | mouseenter | when the mouse pointer is moved onto an element |
onmouseleave | mouseleave | when the mouse pointer is moved out from an element |
onmousemove | mousemove | Fires when the mouse pointer is moving over an element. |
onmouseout | mouseout | Fires when the mouse pointer moves out of an element. |
onmouseover | mouseover | Fires when the mouse pointer moves over an element. |
onmouseup | mouseup | Fires when a mouse button is released over an element. |
onmousewheel | mousewheel | Fire when the mouse wheel rolls up or down over an element. |
onpause | pause | Fires when the media is paused. |
onplay | play | Fires when the media is ready to play. |
onplaying | playing | Fires when the media is playing. |
onprogress | progress | Fires when the browser is in the process of getting the media data. |
onratechange | ratechange | Fires each time the playback rate changes. |
onreset | reset | Fires when the forms Reset button is clicked. |
onresize | resize | Fires when the browser window is resized. |
onscroll | scroll | when an element's scrollbar is being scrolled. |
onseeked | seeked | Fires when the seeking attribute is set to false. |
onseeking | seeking | Fires when the seeking attribute is set to true. |
onselect | select | Fires when any text has been selected in an element. |
onshow | show | Fires when a <menu> element is shown as a context menu |
onsort | sort | Fires when sorting occurs. |
onstalled | stalled | Fires when the browser is unable to fetch the media data. |
onsubmit | submit | Fires when a form is submitted. |
onsuspend | suspend | Fires when fetching the media data is stopped. |
ontimeupdate | timeupdate | Fires when the playing position has changed. |
ontoggle | toggle | Fires when the user opens or closes the <details> element |
onvolumechange | volumechange | Fires each time the volume is changed. |
onwaiting | waiting | Fires when the media has paused. |