Chapters
HTML5 - Syntax
HTML5 - Attributes
HTML5 - Events
HTML5 - Web Forms 2.0
HTML5 - MathML
HTML5 - Web Storage
HTML5 - Web SQL Database
HTML5 - Server Sent Events
HTML5 - WebSockets
HTML5 - Canvas
HTML5 - Audio & Video
HTML5 - Geolocation
HTML5 - Microdata
HTML5 - Drag & Drop
HTML5 - Web Workers
HTML5 - IndexedDB
HTML5 - Web Messaging
HTML5 - CORS
HTML5 - Web RTC
HTML5 - Events
Users, when visiting your website, they carry out different activities like clicking on various text, images, and links, also they hover over certain elements, etc. These activities users perform are called Events.
We can write event handlers in Javascript and then we can further set these event handlers as a value of event tag attribute. The following attributes are made available for events according to HTML5 Attributes.
Attribute | Value | Description |
---|---|---|
offline | script | This HTML5 event is triggered when the document goes offline |
onabort | script | This HTML5 event is triggered on an abort event |
onafterprint | script | This HTML5 event is triggered after the document is printed |
onbeforeonload | script | This HTML5 event is triggered before the document loads |
onbeforeprint | script | This HTML5 event is triggered before the document is printed |
onblur | script | This HTML5 event is triggered when the window loses focus |
oncanplay | script | This HTML5 event is triggered when media can start play, but might has to stop for buffering |
oncanplaythrough | script | This HTML5 event is triggered when media can be played to the end, without stopping for buffering |
onchange | script | This HTML5 event is triggered when an element changes |
onclick | script | This HTML5 event is triggered on a mouse click2 |
oncontextmenu | script | This HTML5 event is triggered when a context menu is triggered |
ondblclick | script | This HTML5 event is triggered on a mouse double-click |
ondrag | script | This HTML5 event is triggered when an element is dragged |
ondragend | script | This HTML5 event is triggered at the end of a drag operation |
ondragenter | script | This HTML5 event is triggered when an element has been dragged to a valid drop target |
ondragleave | script | This HTML5 event is triggered when an element leaves a valid drop target |
ondragover | script | This HTML5 event is triggered when an element is being dragged over a valid drop target |
ondragstart | script | This HTML5 event is triggered at the start of a drag operation |
ondrop | script | This HTML5 event is triggered when dragged element is being dropped |
ondurationchange | script | This HTML5 event is triggered when the length of the media is changed |
onemptied | script | This HTML5 event is triggered when a media resource element suddenly becomes empty. |
onended | script | This HTML5 event is triggered when media has reach the end |
onerror | script | This HTML5 event is triggered when an error occur |
onfocus | script | This HTML5 event is triggered when the window gets focus |
onformchange | script | This HTML5 event is triggered when a form changes |
onforminput | script | This HTML5 event is triggered when a form gets user input |
onhaschange | script | This HTML5 event is triggered when the document has change |
oninput | script | This HTML5 event is triggered when an element gets user input |
oninvalid | script | This HTML5 event is triggered when an element is invalid |
onkeydown | script | This HTML5 event is triggered when a key is pressed |
onkeypress | script | This HTML5 event is triggered when a key is pressed and released |
onkeyup | script | This HTML5 event is triggered when a key is released |
onload | script | This HTML5 event is triggered when the document loads |
onloadeddata | script | This HTML5 event is triggered when media data is loaded |
onloadedmetadata | script | This HTML5 event is triggered when the duration and other media data of a media element is loaded |
onloadstart | script | This HTML5 event is triggered when the browser starts to load the media data |
onmessage | script | This HTML5 event is triggered when the message is triggered |
onmousedown | script | This HTML5 event is triggered when a mouse button is pressed |
onmousemove | script | This HTML5 event is triggered when the mouse pointer moves |
onmouseout | script | This HTML5 event is triggered when the mouse pointer moves out of an element |
onmouseover | script | This HTML5 event is triggered when the mouse pointer moves over an element |
onmouseup | script | This HTML5 event is triggered when a mouse button is released |
onmousewheel | script | This HTML5 event is triggered when the mouse wheel is being rotated |
onoffline | script | This HTML5 event is triggered when the document goes offline |
online | script | This HTML5 event is triggered when the document comes online |
ononline | script | This HTML5 event is triggered when the document comes online |
onpagehide | script | This HTML5 event is triggered when the window is hidden |
onpageshow | script | This HTML5 event is triggered when the window becomes visible |
onpause | script | This HTML5 event is triggered when media data is paused |
onplay | script | This HTML5 event is triggered when media data is going to start playing |
onplaying | script | This HTML5 event is triggered when media data has start playing |
onpopstate | script | This HTML5 event is triggered when the window's history changes |
onprogress | script | This HTML5 event is triggered when the browser is fetching the media data |
onratechange | script | This HTML5 event is triggered when the media data's playing rate has changed |
onreadystatechange | script | This HTML5 event is triggered when the ready-state changes |
onredo | script | This HTML5 event is triggered when the document performs a redo |
onresize | script | This HTML5 event is triggered when the window is resized |
onscroll | script | This HTML5 event is triggered when an element's scrollbar is being scrolled |
onseeked | script | This HTML5 event is triggered when a media element's seeking attribute is no longer true, and the seeking has ended |
onseeking | script | This HTML5 event is triggered when a media element's seeking attribute is true, and the seeking has begun |
onselect | script | This HTML5 event is triggered when an element is selected |
onstalled | script | This HTML5 event is triggered when there is an error in fetching media data |
onstorage | script | This HTML5 event is triggered when a document loads |
onsubmit | script | This HTML5 event is triggered when a form is submitted |
ontimeupdate | script | This HTML5 event is triggered when media changes its playing position |
onundo | script | This HTML5 event is triggered when a document performs an undo |
onunload | script | This HTML5 event is triggered when the user leaves the document |
onvolumechange | script | This HTML5 event is triggered when media changes the volume, also when volume is set to "mute" |
onwaiting | script | This HTML5 event is triggered when media has stopped playing, but is expected to resume |