- HTML Tutorial
- HTML - Home
- HTML - Introduction
- HTML - Editors
- HTML - Basic Tags
- HTML - Elements
- HTML - Attributes
- HTML - Headings
- HTML - Paragraphs
- HTML - Fonts
- HTML - Blocks
- HTML - Style Sheet
- HTML - Formatting
- HTML - Quotations
- HTML - Comments
- HTML - Colors
- HTML - Images
- HTML - Image Map
- HTML - Iframes
- HTML - Phrase Elements
- HTML - Meta Tags
- HTML - Classes
- HTML - IDs
- HTML - Backgrounds
- HTML Tables
- HTML - Tables
- HTML - Headers & Caption
- HTML - Table Styling
- HTML - Table Colgroup
- HTML - Nested Tables
- HTML Lists
- HTML - Lists
- HTML - Unordered Lists
- HTML - Ordered Lists
- HTML - Definition Lists
- HTML Links
- HTML - Text Links
- HTML - Image Links
- HTML - Email Links
- HTML Color Names & Values
- HTML - Color Names
- HTML - RGB
- HTML - HEX
- HTML - HSL
- HTML Forms
- HTML - Forms
- HTML - Form Attributes
- HTML - Form Control
- HTML - Input Attributes
- HTML Media
- HTML - Video Element
- HTML - Audio Element
- HTML - Embed Multimedia
- HTML Header
- HTML - Head Element
- HTML - Adding Favicon
- HTML - Javascript
- HTML Layouts
- HTML - Layouts
- HTML - Layout Elements
- HTML - Layout using CSS
- HTML - Responsiveness
- HTML - Symbols
- HTML - Emojis
- HTML - Style Guide
- HTML Graphics
- HTML - SVG
- HTML - Canvas
- HTML APIs
- HTML - Geolocation API
- HTML - Drag & Drop API
- HTML - Web Workers API
- HTML - WebSocket
- HTML - Web Storage
- HTML - Server Sent Events
- HTML Miscellaneous
- HTML - MathML
- HTML - Microdata
- HTML - IndexedDB
- HTML - Web Messaging
- HTML - Web CORS
- HTML - Web RTC
- HTML Demo
- HTML - Audio Player
- HTML - Video Player
- HTML - Web slide Desk
- HTML Tools
- HTML - Velocity Draw
- HTML - QR Code
- HTML - Modernizer
- HTML - Validation
- HTML - Color Picker
- HTML References
- HTML - Cheat Sheet
- HTML - Tags Reference
- HTML - Attributes Reference
- HTML - Events Reference
- HTML - Fonts Reference
- HTML - ASCII Codes
- ASCII Table Lookup
- HTML - Color Names
- HTML - Entities
- MIME Media Types
- HTML - URL Encoding
- Language ISO Codes
- HTML - Character Encodings
- HTML - Deprecated Tags
- HTML Resources
- HTML - Quick Guide
- HTML - Useful Resources
- HTML - Color Code Builder
- HTML - Online Editor
HTML - Events Reference
When users visit your website, they do things like click various links, bring mouse over text and images etc. These are examples of what we call events in JavaScript and VBScript terminologies.
We can write our event handlers using JavaScript or VBScript and can specify some actions to be taken against these events. Though these are the events but they will be specified as attributes for the HTML tags.
The HTML 4.01 specification had defined 19 events but later HTML-5 has added many other events which we have listed down here −
Window Events Attributes
Following are the window events attributes that are listed below −
Sr.No | Events & Description |
---|---|
1 | onafterprint Triggers after a document is printed |
2 | onbeforeprint Triggers before a document is printed |
3 | onbeforeunload Triggers before a document loads |
4 | onerror Triggers when an error occurs |
5 | onhashchange Triggers when a document has changed |
6 | onload Triggers when a document loads |
7 | onoffline Triggers when a document goes offline |
8 | ononline Triggers when a document comes online |
9 | onpagehide Triggers when a window is hidden |
10 | onpageshow Triggers when a window becomes visible |
11 | onresize Triggers when a window is resized |
12 | onunload Triggers when a user leaves the document |
Form Events
Following are the Form events attributes that are listed below −
Sr.No | Events & Description |
---|---|
1 | onblur Triggers when a window loses focus |
2 | onchange Triggers when an element changes |
3 | oncontextmenu Triggers when a context menu is triggered |
4 | onfocus Triggers when a window gets focus |
5 | oninput Triggers when an element gets user input |
6 | oninvalid Triggers when an element is invalid |
7 | onreset Triggers when a form is reset |
8 | onsearch The HTML onsearch event allows to run specific JavaScript code when a user conducts a search action within a searchable input field. |
9 | onselect Triggers when an element is selected |
10 | onsubmit Triggers when a form is submitted |
Keyboard Events
Following are the HTML Keyboard Events that are listed below −
Sr.No | Events & Description |
---|---|
1 | onkeydown Triggers when a key is pressed |
2 | onkeyup Triggers when a key is released |
Mouse Events
Following are the Mouse events attributes that are listed below −
Sr.No | Events & Description |
---|---|
1 | onclick Triggers on a mouse click |
2 | ondblclick Triggers on a mouse double-click |
3 | onmousedown Triggers when a mouse button is pressed |
4 | onmousemove Triggers when the mouse pointer moves |
5 | onmouseout Triggers when the mouse pointer moves out of an element |
6 | onmouseover Triggers when the mouse pointer moves over an element |
7 | onmouseup Triggers when a mouse button is released |
8 | onwheel When the mouse wheel is over an element, the HTML onwheel event takes place. |
Drag Events
Following are the HTML drag events that are listed below −
Sr.No | Events & Description |
---|---|
1 | ondrag Triggers when an element is dragged |
2 | ondragend Triggers at the end of a drag operation |
3 | ondragenter Triggers when an element has been dragged to a valid drop target |
4 | ondragleave Triggers when an element leaves a valid drop target |
5 | ondragover Triggers when an element is being dragged over a valid drop target |
6 | ondragstart Triggers at the start of a drag operation |
7 | ondrop Triggers when a dragged element is being dropped |
8 | onscroll Triggers when an element's scrollbar is being scrolled |
Clipboard Events
Let's look into the following clipboard events that are listed below −
Sr.No | Events & Description |
---|---|
1 | oncopy Triggers when an element is copied by the user |
2 | oncut Triggers when an element is removed (cut) by the user |
3 | onpaste Triggers when an element is being pasted into an input field. |
Media Events
Following are the Media events attributes that are listed below −
Sr.No | Events & Description |
---|---|
1 | ondurationchange Triggers when the length of a media is changed |
2 | onended Triggers when a media has reached the end |
3 | onerror Triggers when an error occurs |
4 | onloadeddata Triggers when media data is loaded |
5 | onloadedmetadata Triggers when the duration and other media data of a media element is loaded |
6 | onloadstart Triggers when the browser starts loading the media data |
7 | onpause Triggers when media data is paused |
8 | onplay Triggers when media data is going to start playing |
9 | onplaying Triggers when media data has started playing |
10 | onprogress Triggers when the browser is fetching the media data |
11 | onratechange Triggers when the playing rate of media data has changed |
12 | onseeked Triggers when the seeking attribute of a media element is no longer true, and the seeking has ended |
13 | onseeking Triggers when the seeking attribute of a media element is true, and the seeking has begun |
14 | onstalled Triggers when there is an error in fetching media data |
15 | onsuspend Triggers when the browser has been fetching media data, but stopped before the entire media file was fetched |
16 | ontimeupdate Triggers when media changes its playing position |
17 | onvolumechange Triggers when a media changes the volume, also when volume is set to "mute" |
18 | onwaiting Triggers when media has stopped playing, but is expected to resume |
Misc Events
Following the misc event listed below −
Sr.No | Event & Description |
---|---|
1 | ontoggle In general, the toggle means it toggles between hide() and show() for the selected element. |