HTML Event Attributes represents an event and can be triggered when any user action occurs on specified element. Mostly all event attributes are supported by web browsers in HTML5 documents.
Available HTML Event Attributes
Listed below are the most common HTML event attributes that can be added to any available HTML elements to define events or actions.
Form Event Attributes
Listed below are the common form event attributes that mostly fired on HTML Form elements when any user action triggered but can be fired on all other HTML elements also.
Attribute | Value | Description |
---|---|---|
onblur | script | Event fires immediately after the specified element loses focus |
onchange | script | Event fires immediately when element value is changed |
oncontextmenu | script | Event fires immediately when context menu is triggered |
onfocus | script | Event fires immediately after the specified element gets focus |
onformchange | script | Event fires immediately when a form changes |
onforminput | script | Event fires immediately when a form gets user input |
oninput | script | Event fires immediately when an element gets user input |
oninvalid | script | Event fires immediately when an element is invalid |
onreset | script | Event fires immediately when user clicked on a form reset button |
onselect | script | Event fires immediately after the specified element gets selected |
onsubmit | script | Event fires immediately when a form is submitted |
Keyboard Event Attributes
Listed below are the common keyboard event attributes that mostly fired when user take action using keyboard keys.
Attribute | Value | Description |
---|---|---|
onkeydown | script | Event fires immediately when user is pressing a down key from keyboard |
onkeypress | script | Event fires immediately when user presses a key from keyboard |
onkeyup | script | Event fires immediately when user releases a key from keyboard |
Mouse Event Attributes
Listed below are the common mouse event attributes that mostly fired on any mouse action.
Attribute | Value | Description |
---|---|---|
onclick | script | Event fires immediately when mouse clicked on the specified element |
ondblclick | script | Event fires immediately when mouse double-click on the specified element |
ondrag | script | Event fires immediately when the specified element is dragged |
ondragend | script | Event fires immediately after ondrag event finished or at the end of a drag operation |
ondragenter | script | Event fires immediately when the specified element has been dragged to any valid drop target |
ondragleave | script | Event fires immediately when the specified element leaves any valid drop target |
ondragover | script | Event fires immediately when the specified element dragged over any valid drop target |
ondragstart | script | Event fires immediately when start of drag operation for specified element |
ondrop | script | Event fires immediately when dragged element is dropped |
onmousedown | script | Event fires immediately when mouse pointer gets down from an element |
onmousemove | script | Event fires immediately when mouse pointer moves over an element |
onmouseout | script | Event fires immediately when mouse pointer gets out from an element |
onmouseover | script | Event fires immediately when mouse pointer moves over an element |
onmouseup | script | Event fires immediately when a mouse pointer is released over an element |
onmousewheel | script | Event fires immediately when mouse wheel being rotated |
onscroll | script | Event fires immediately when the specified element gets scrolled |
Media Event Attributes
Listed below are the common media event attributes that mostly fired on any media objects like <embed>, <object>, <audio>, <video> etc.
Attribute | Value | Description |
---|---|---|
onabort | script | Event fires immediately when element is aborted |
oncanplay | script | Event fires when specified file is ready to start playing |
oncanplaythrough | script | Event fires when specified file played till end without pausing for buffering |
ondurationchange | script | Event fires when length of the media changed |
onemptied | script | Event fires when specified media file becomes unavailable or disconnected from server unexpectedly |
onended | script | Event fires when specified media file reached at the end point |
onerror | script | Event fires when media file error occurs while loading |
onloadeddata | script | Event fires when specified media’s data is loaded |
onloadedmetadata | script | Event fires when specified media’s metadata is loaded |
onloadstart | script | Event fires when media file starts loading |
onpause | script | Event fires when media file is paused |
onplay | script | Event fires when media file is ready to play |
onplaying | script | Event fires when media file is start for playing |
onprogress | script | Event fires when web browser is processing for getting the media file data |
onratechange | script | Event fires when media playback rate changed |
onreadystatechange | script | Event fires when ready state changed for each and every time |
onseeked | script | Event fires when seeking attribute value is set to false which indicates media seeking is finished or ended |
onseeking | script | Event fires when seeking attribute value is set to true which indicates media seeking is running or active |
onstalled | script | Event fires whenever web browser is unable to get or fetch media file data for any reason |
onsuspend | script | Event fires whenever web browser fetching the media data is stopped before completely loaded for any reason |
ontimeupdate | script | Event fires whenever playing position has been changed |
onvolumechange | script | Event fires whenever volume is changed |
onwaiting | script | Event fires when media file is paused specially for buffering and expected again to play or resume same media file |
Window Event Attributes
Listed below are the common window events attributes specified with <body> tag and mostly fired on any window object.
Attribute | Value | Description |
---|---|---|
onafterprint | script | Event fires immediately after the document is printed |
onbeforeprint | script | Event fires before the document is printed |
onbeforeunload | script | Event fires before the document is unloaded |
onerror | script | Event fires when any error occurs |
onhaschange | script | Event fires when document has been changed |
onload | script | Event fires immediately after page load |
onmessage | script | Event fires when message is triggered out |
onoffline | script | Event fires immediately when document goes to offline mode |
ononline | script | Event fires immediately when document comes in online mode |
onpagehide | script | Event fires whenever document window becomes hidden |
onpageshow | script | Event fires whenever document window becomes visible |
onpopstate | script | Event fires whenever document window’s history has been changed |
onredo | script | Event fires when the document performs redo operation |
onresize | script | Event fires whenever document window is resized |
onstorage | script | Event fires whenever a web browser storage area is updated |
onundo | script | Event fires when the document performs undo operation |
onunload | script | Event fires immediately after page unloaded or web browser’s window has been closed |