HTML Event Attributes

You are Here:

HTML Event Attributes

In HTML, an event is something that-happen in the system. For example, user clicks an element (button, link, etc.) is an event, page load is an event, hovering an element is an event, and so.

In this section, we will list all event attributes available in HTML.

Form Event Attributes

The following table provides a list of all Form Event Attributes available in HTML.

AttributeValueExplanation
onblurscriptScript runs when the element loses focus.
onchangescriptScript runs when the value of the element is changed and loses focus.
onfocusscriptScript runs when the element gets focus.
oninputscriptScript runs when an element gets user input.
oninvalidscriptScript runs when an element is invalid.
onresetscriptScript runs when the reset button in a form is click.
onsearchscriptScript runs when the user type something in a search field.i.e) <input type="search">.
onselectscriptScript runs when some text has been selected in an element.
onsubmitscriptScript runs when a form is submitted.

Keyboard Event Attributes

The following table provides a list of all Keyboard Event Attributes available in HTML.

AttributeValueExplanation
onkeydownscriptScript runs when a user is pressing a key.
onkeypressscriptScript runs when a user presses a key.
onkeyupscriptScript runs when a user releases a key.

Mouse Event Attributes

The following table provides a list of all Mouse Event Attributes available in HTML.

AttributeValueExplanation
onclickscriptScript runs when a mouse click on the element.
oncontextmenuscriptScript runs when the element is right clicked.
ondblclickscriptScript runs when a mouse is double-click on the element.
onmousedownscriptScript runs when a mouse button is pressed down on an element.
onmousemovescriptScript runs when the mouse pointer is moving while it is over an element.
onmouseoutscriptScript runs when the mouse pointer moves out of an element.
onmouseoverscriptScript runs when the mouse pointer moves over an element.
onmouseupscriptScript runs when a mouse button is released over an element.
ontogglescriptScript runs when the user clicks the <details> element to open or close the content inside it.
onwheelscriptScript runs when the mouse wheel rolls up or down over an element.

Drag Event Attributes

The following table provides a list of all Drag Event Attributes available in HTML.

AttributeValueExplanation
ondragscriptScript runs when an element is dragged.
ondragendscriptScript runs at the end of a drag operation.
ondragenterscriptScript runs when when an element has been dragged to a valid drop target.
ondragleavescriptScript runs when an element leaves a valid drop target.
ondragoverscriptScript runs when an element is being dragged over a valid drop target.
ondragstartscriptScript runs at the start of a drag operation.
ondropscriptScript runs when dragged element is being dropped.
onscrollscriptScript runs when an element's scrollbar is being scrolled.

Clipboard Event Attributes

The following table provides a list of all Clipboard Event Attributes available in HTML.

AttributeValueExplanation
oncopyscriptScript runs when the user copies the content of an element.
oncutscriptScript runs when the user cuts the content of an element.
onpastescriptScript runs when the user paste some content in an element.

Media Event Attributes

The following table provides a list of all Media Event Attributes available in HTML.

AttributeValueExplanation
onabortscriptScript runs a media is aborted.
oncanplayscriptScript runs when a media is ready to start playing.
oncanplaythroughscriptScript runs when a file can be played all the way to the end without pausing for buffering.
oncuechangescriptScript runs when the cue changes in a <track> element.
ondurationchangescriptScript runs when the length of the media changes.
onemptiedscriptScript runs when something bad happens and the file is suddenly unavailable.
onendedscriptScript runs when the media has reach the end.
onerrorscriptScript runs when an error occurs when the file is being loaded.
onloadeddatascriptScript runs when media data is loaded.
onloadedmetadatascriptScript runs when when meta data (duration, dimensions, etc) are loaded.
onloadstartscriptScript runs when the browser has started to load a media (resource).
onpausescriptScript runs when the media is paused.
onplayscriptScript runs when the media is ready to start playing.
onplayingscriptScript runs when the media actually has started playing.
onprogressscriptScript runs when the browser is in the process of getting the media data.
onratechangescriptScript runs when each time the playback rate changes(either forward or backward).
onseekedscriptScript runs when the current playback position of a video/audio has changed.
onseekingscriptScript runs when the audio/video is seeking a new position.
onstalledscriptScript runs when the browser is trying to fetch media data, but data is unexpectedly not forthcoming.
onsuspendscriptScript runs when fetching the media data is stopped before it is completely loaded.
ontimeupdatescriptScript runs when the time indicated by the currentTime attribute has been updated.
onvolumechangescriptScript runs when each time the volume of a video/audio has been changed.
onwaitingscriptScript runs when the video stops because of a temporary lack of data.

Window Event Attributes

The following table provides a list of all Window Event Attributes available in HTML.

AttributeValueExplanation
onafterprintscriptScript runs when a page has started printing, or the print preview has been closed.
onbeforeprintscriptScript runs when a page is about to be printed, or previewed for printing.
onbeforeunloadscriptScript runs when the document is about to be unloaded.
onhashchangescriptScript runs when the current URL changes to target a specific section within the page.
onloadscriptScript runs after the page is finished loading.
onmessagescriptScript runs when the message is triggered.
onofflinescriptScript runs when the browser starts to work offline.
ononlinescriptScript runs when the browser starts to work online.
onpagehidescriptScript runs when a user navigates away from a page.
onpageshowscriptScript runs when a user navigates to a page.
onpopstatescriptScript runs when the window's history changes.
onresizescriptScript runs when the browser window has been resized.
onunloadscriptScript runs when the document/page or a child resource is being unloaded.

Reminder

Hi Developers, we almost covered 99.5% of HTML Tutorials with examples for quick and easy learning.

We are working to cover every Single Concept in HTML.

Please do google search for:

Join Our Channel

Join our telegram channel to get an instant update on depreciation and new features on HTML, CSS, JavaScript, jQuery, Node.js, PHP and Python.

This channel is primarily useful for Full Stack Web Developer.

Share this Page

Meet the Author