HTML CSS Bootstrap Javascript Icons Python
HTML References
HTML - Tag Reference HTML - Tag by Category HTML - Attributes HTML - Global Attributes HTML - Events HTML - Language Codes HTML - Country Codes HTML - URL Encoding HTTP Methods HTTP Status Codes <input> types
All HTML Tags
<!-- --> <!DOCTYPE> <a> <abbr> <acronym> <address> <applet> <area> <article> <aside> <audio> <b> <base> <basefont> <bdi> <bdo> <big> <blockquote> <body> <br> <button> <canvas> <caption> <center> <cite> <code> <col> <colgroup> <data> <datalist> <dd> <del> <details> <dfn> <dialog> <dir> <div> <dl> <dt> <em> <embed> <fieldset> <figcaption> <figure> <font> <footer> <form> <frame> <frameset> <h1> - <h6> <head> <header> <hr> <html> <i> <iframe> <img> <input> <ins> <kbd> <label> <legend> <li> <link> <main> <map> <mark> <meta> <meter> <nav> <noframes> <noscript> <object> <ol> <optgroup> <option> <output> <p> <param> <picture> <pre> <progress> <q> <rp> <rt> <ruby> <s> <samp> <script> <section> <select> <small> <source> <span> <strike> <strong> <style> <sub> <summary> <sup> <svg> <table> <tbody> <td> <template> <textarea> <tfoot> <th> <thead> <time> <title> <tr> <track> <tt> <u> <ul> <var> <video> <wbr>

HTML Event Attributes

The HTML event attributes are global and can be applied to most of the elements.

Events are actions that happen in the system you are programming, which the system tells you about so you can respond to them in some way if desired. For example When the page loads, it is called an event. When the user clicks a button, that click is an event.

Move your mouse over the box below and see how it works:

Resource Events

Event Description
onbeforeunload The event occurs when the document is about to be unloaded
oncached The resources listed in the manifest have been downloaded, and the application is now cached
onerror The event triggers when a resource failed to load
onhashchange The event occurs when there has been changes to the anchor part of the a URL
onload The event occurs after the page is finished loading
onunload The event occurs once a page has unloaded
onstorage The event occurs when a Web Storage area is updated

Network Events

Event Description
onoffline The event occurs when the browser starts to work offline
ononline The event occurs when the browser starts to work online

Keyboard Events

Event Description
onkeydown The event occurs when the user is pressing a key
onkeypress The event occurs when the user presses a key
onkeyup The event occurs when the user releases a key

Printing Events

Event Description
onafterprint The event occurs after the document is printed
onbeforeprint The event occurs before the document is printed

Mouse Events

Event Description
onclick The event occurs when the user clicks on an element
ondblclick The event occurs when the user double-clicks on an element
oncontextmenu The event occurs when the user right-clicks on an element to open a context menu
onmousedown The event occurs when the user presses a mouse button over an element
onmouseup The event occurs when a user releases a mouse button over an element
onmouseenter The event occurs when the pointer is moved onto an element
onmouseleave The event occurs when the pointer is moved out of an element
onmousemove The event occurs when the pointer is moving while it is over an element
onmouseover The event occurs when the pointer is moved onto an element, or onto one of its children
onmouseout The event occurs when a user moves the mouse pointer out of an element, or out of one of its children
onwheel The event occurs when the mouse wheel rolls up or down over an element



Form Events

Event Description
onfocus The event occurs when an element gets focus
onblur The event occurs when an element loses focus
onchange The event occurs when the content of a form is changed
oninput The event occurs when an element gets user input
onselect The event occurs after the user selects some text (input and textarea)
oninvalid The event occurs when an element is invalid
onsearch The event occurs when the user writes something in a search field
onsubmit The event occurs when a form is submitted
onreset The event occurs when a form is reset

Drag Events

Event Description
ondrag The event occurs when an element is being dragged
ondragend The event occurs when the user has finished dragging an element
ondragenter The event occurs when the dragged element enters the drop target
ondragleave The event occurs when the dragged element leaves the drop target
ondragover The event occurs when the dragged element is over the drop target
ondragstart The event occurs when the user starts to drag an element
ondrop The event occurs when the dragged element is dropped on the drop target

Clipboard Events

Event Description
oncopy The event occurs when the user copies the content of an element
oncut The event occurs when the user cut the content of an element
onpaste The event occurs when the user paste the content of an element

Media Events

Event Description
onabort The event occurs on abort
oncanplay The event occurs when a file is ready to start playing
oncanplaythrough The event occurs when a file can be played all the way to the end without pausing for buffering
oncuechange The event occurs when the cue changes in a <track> element
ondurationchange The event occurs when the duration of the media changes
onemptied The event occurs when something bad happens and the file is suddenly unavailable
onended The event occurs when the media has reach the end
onloadeddata The event occurs when media data is loaded
onloadedmetadata The event occurs when metadata are loaded
onloadstart The event occurs when the file begins to load
onpause The event occurs when the media is paused
onplay The event occurs when the media is ready to play
onprogress The event occurs when the browser is in the process of getting the media data
onratechange The event occurs when a user switches to a slow motion or fast forward mode
onseeking The event occurs when the user start seeking media
onseeked The event occurs after seeking
onstalled The event occurs when the browser is unable to fetch the media data
onsuspend The event occurs when fetching the media data is stopped before it is completely loaded
ontimeupdate The event occurs when the playing position has changed
onvolumechange The event occurs when the volume is changed
onwaiting The event occurs when the media pauses to buffer more data

Websocket Events
Event Description
onopen A WebSocket connection has been established
onmessage A message is received through a WebSocket
onerror A WebSocket connection has been closed with prejudice (some data couldn't be sent for example)
onclose A WebSocket connection has been closed

Session History Events
Event Description
onpagehide A session history entry is being traversed from
onpageshow A session history entry is being traversed to
onpopstate A session history entry is being navigated to (in certain cases)

View Events
Event Description
onfullscreenchange An element was turned to fullscreen mode or back to normal mode
onfullscreenerror It was impossible to switch to fullscreen mode for technical reasons or because the permission was denied
onresize The event occurs when the browser window is resized
onscroll The document view or an element has been scrolled

CSS Animation Events
Event Description
onanimationstart A CSS animation has started
onanimationend A CSS animation has completed
onanimationiteration A CSS animation is repeated

CSS Transition Events
Event Description
ontransitionstart A CSS transition has actually started (fired after any delay)
ontransitioncancel A CSS transition has been cancelled
ontransitionend A CSS transition has completed
ontransitionrun A CSS transition has begun running (fired before any delay starts)

Misc
Event Description
ontoggle The event occurs when the user opens or closes the <details> element

Last updated: Friday 24 Aug, 2018