HTML Event Attributes Complete Reference Improve Improve Improve Like Article Like Save Article Save Share Report issue Report Events are actions that happen in the browser when the user does something For example when users click on the mouse or type something on the keyboard. HTML Event Attributes: In HTML, we can use event actions on the browser, and with the help of the event, the user responds to the system. Event Attributes can be used with HTML elements to perform various actions. Example : HTML <!DOCTYPE html> <html> <head> <title>onbeforeprint attribute</title> <style> body { text-align:center; } h1 { color:green; } </style> </head> <body onbeforeprint="myFunction()"> <h1>GeeksforGeeks</h1> <h2>onbeforeprint attribute</h2> <!-- The script run when page will ready to print --> <script> function myFunction() { alert("This document is ready to be printed"); } </script> </body> </html> Output: The complete list of Event Attributes are given below: Window Event Attributes Window Event Attributes Description Example onafterprint This attribute is used together with the onbeforeprint attribute. Try onbeforeprint The alert message display before the print dialogue box appears. Try onbeforeunload The onbeforeunload event run when the document is about to be unloaded. Try onerror This attribute works when an error occurs while loading an external file. Try onhashchange This attribute works when there has been changes to the anchor part. Try onload This attribute works when an object has been loaded. Try onoffline The onoffline event attribute works when the browser work in offline mode. ononline The ononline event attribute works when the browser starts working in online mode. onpageshow This event occurs when a user navigates to a website. onresize The onresize event attribute is triggered each time when resize the browser window size. Try onunload The onunload event attribute works when the document is being unloaded i.e. Form Event Attributes Form Event Attributes Description Example onblur This attribute is mostly used in Form validation code. Try onchange The onchange event attribute works when the value of the element changes and select the new value from the List. Try oncontextmenu This attribute works when the user right-clicks on an element to open the context menu. Try onfocus This event attribute is mostly used with <input>, <select>, <a> elements. Try oninput This attribute works when it gets user input value. Try oninvalid The oninvalid event attribute works when an input field values are invalid or empty. Try onreset The onreset event attribute in HTML is triggered when reset the form. Try onsearch When a user presses the ENTER button or click on the x button. Try onselect The onselect event attribute works when some text has been selected in an element. Try onsubmit The onsubmit event attribute in HTML is triggered when a form is submitted. Try Keyboard Event Attributes Keyboard Event Attributes Description Example onkeydown This onkeydown event attribute works when user presses any key from the keyboard Try onkeypress This attribute fires when a user presses a key on the Keyboard. Try onkeyup This onkeyup event attribute works when the user releases the key from the keyboard. Try Mouse Event Attributes Mouse Event Attributes Description Example onclick The onclick event attribute in HTML works when the user clicks on the button. Try ondblclick This Attribute Event occurs when a user fires mouse Double click on the Element. Try onmousedown when a mouse button is pressed down on the element Try onmousemove The onmousemove attribute works when the pointer moves over an element. Try onmouseout when the mouse pointer moves out of the specified element. Try onmouseover The onmouseover event attribute works when the mouse pointer moves over the specified element. Try onmouseup when a mouse button is released over the element. Try onwheel when the wheel of pointer device is rolled up or down over an element. Drag Event Attributes Drag Event Attributes Description Example ondrag when the element or text selection is being dragged in HTML Try ondragend when the user finished the dragging of element. The drag and drop feature is common in HTML5 Try ondragenter The ondragenter event attribute in HTML works when the content is draggable Try ondragleave The ondragleave attribute works when a draggable element or text selection leaves a valid drop target Try ondragstart HTML ondragstart Event Attribute is used when the user wants to drag the text or element. Try ondrop The ondrop event attribute is used to drag an element or text and drop it into a valid droppable location or target. Try onscroll This onscroll attribute works when an element scrollbar is being scrolled. Try Clipboard Events Attributes Clipboard Events Attributes Description EDescription oncopy This attribute fires when the user copied the content present in an element. Try oncut This attribute fires when the user cut or delete the content that has been present in the element. Try onpaste The onpaste attribute works when some content are paste in an element. Try Misc Events Attributes Misc Events Attributes Description Example ontoggle The ontoggle event is triggered when the user open or close the <details> element. Try Last Updated : 08 Dec, 2022 Like Article Save Article Previous HTML dir Attribute Next JavaScript Operators Reference Share your thoughts in the comments Add Your Comment Please Login to comment...