HTML 5 Event Attributes

|  | Search W3Schools : |

HOME | HTML | CSS | XML | JAVASCRIPT | ASP | PHP | SQL | MORE... |  | References | Examples | Forum | About

ADVERTISEMENTS XML Certification Download XML editor Custom Programming |  |

Table of contents

HTML 5 Reference
HTML 5 by Alphabet
HTML 5 Attributes
HTML 5 Events
HTML5 Tags
<!-->
<!DOCTYPE>
<a>
<abbr>
<acronym>
<address>
<applet>
<area>
<article>
<aside>
<audio>
<b>
<base>
<basefont>
<bdo>
<big>
<blockquote>
<body>
<br>
<button>
<canvas>
<caption>
<center>
<cite>
<code>
<col>
<colgroup>
<command>
<datagrid>
<datalist>
<datatemplate>
<dd>
<del>
<details>
<dialog>
<dfn>
<dir>
<div>
<dl>
<dt>
<em>
<embed>
<event-source>
<fieldset>
<figure>
<font>
<footer>
<form>
<frame>
<frameset>
<head>
<header>
<h1> - <h6>
<hr>
<html>
<i>
<iframe>
<img>
<input>
<ins>
<kbd>
<label>
<legend>
<li>
<link>
<m>
<map>
<menu>
<meta>
<meter>
<nav>
<nest>
<noframes>
<noscript>
<object>
<ol>
<optgroup>
<option>
<output>
<p>
<param>
<pre>
<progress>
<q>
<rule>
<s>
<samp>
<script>
<section>
<select>
<small>
<source>
<span>
<strike>
<strong>
<style>
<sub>
<sup>
<table>
<tbody>
<td>
<textarea>
<tfoot>
<th>
<thead>
<time>
<title>
<tr>
<tt>
<u>
<ul>
<var>
<video>

Selected Reading

Web Statistics
Web Glossary
Web Hosting
Web Quality
W3Schools Tutorials
W3Schools Forum
Helping W3Schools

# HTML 5 Event Attributes

## Standard Event Attributes

HTML 4 added the ability to let events trigger actions in a browser, like starting a JavaScript when a user clicks on an element.

To learn more about programming events, please visit our JavaScript tutorial and our DHTML tutorial.

Below is the standard event attributes that can be inserted into HTML 5 elements to define event actions.

## Differences Between HTML 4.01 and HTML 5

New event attributes in HTML 5: onabort, onbeforeunload, oncontextmenu, ondrag, ondragend, ondragenter, ondragleave, ondragover, ondragstart, ondrop, onerror, onmessage, onmousewheel, onresize, onscroll, and onunload.

HTML 4.01 event attributes which are no longer supported: onreset.

## Event Attributes

- 4: indicates if the attribute is defined in HTML 4.01
- 5: indicates if the attribute is defined in HTML 5

Attribute | Value | Description | 4 | 5
--- | --- | --- | --- | ---
onabort | script | Script to be run on an abort event |  | 5
onbeforeonload | script | Script to be run before an element is loaded |  | 5
onblur | script | Script to be run when the element loses focus | 4 | 5
onchange | script | Script to be run when the element changes | 4 | 5
onclick | script | Script to be run on a mouse click | 4 | 5
oncontextmenu | script | Script to be run when a context menu is triggered |  | 5
ondblclick | script | Script to be run on a mouse double-click | 4 | 5
ondrag | script | Script to be run when an element is dragged |  | 5
ondragend | script | Script to be run at the end of a drag operation |  | 5
ondragenter | script | Script to be run when an element has been dragged to a valid drop target |  | 5
ondragleave | script | Script to be run when an element leaves a valid drop target |  | 5
ondragover | script | Script to be run when an element is being dragged over a valid drop target |  | 5
ondragstart | script | Script to be run at the start of a drag operation |  | 5
ondrop | script | Script to be run when dragged element is being dropped |  | 5
onerror | script | Script to be run when an error occur during the loading of an element |  | 5
onfocus | script | Script to be run when the element gets focus | 4 | 5
onkeydown | script | Script to be run when key is pressed | 4 | 5
onkeypress | script | Script to be run when key is pressed and released | 4 | 5
onkeyup | script | Script to be run when key is released | 4 | 5
onload | script | Script to be run when a document loads | 4 | 5
onmessage | script | Script to be run when the message event is being triggered |  | 5
onmousedown | script | Script to be run when a mouse button is pressed | 4 | 5
onmousemove | script | Script to be run when the mouse pointer moves | 4 | 5
onmouseover | script | Script to be run when the mouse pointer moves over an element | 4 | 5
onmouseout | script | Script to be run when the mouse pointer moves out of an element | 4 | 5
onmouseup | script | Script to be run when a mouse button is released | 4 | 5
onmousewheel | script | Script to be run when the mouse wheel is being rotated |  | 5
onreset | script | Script to be run when the form is reset. Not supported | 4 |
onresize | script | Script to be run when the element is being resized |  | 5
onscroll | script | Script to be run when the element's scrollbar is scrolled |  | 5
onselect | script | Script to be run when the element is selected | 4 | 5
onsubmit | script | Script to be run when the form is submitted | 4 | 5
onunload | script | Script to be run when a document unloads |  | 5

## Learn XML with <oXygen/> XML Editor - Free Trial!

oXygen helps you learn to define, edit, validate and transform XML documents. Supported technologies include XML Schema, DTD, Relax NG, XSLT, XPath, XQuery, CSS.

Understand in no time how XSLT and XQuery work by using the intuitive oXygen debugger!

Do you have any XML related questions? Get free answers from the oXygen XML forum and from the video demonstrations.

Download a FREE 30-day trial today!

WEB HOSTING
Domain Name Registration & More!
$15 Domain Name Registration Save $20 / year!
Buy UK Domain Names Register Domain Names
Cheap Domain Names Cheap Web Hosting
Best Web Hosting
PHP MySQL Hosting
Top 10 Web Hosting
UK Reseller Hosting
Web Hosting
FREE Web Hosting

WEB BUILDING
Website Templates Flash Templates Website Builder Internet Business Opportunity
Custom Programming
FREE Trial or Demo Web Content Manager Forms,Web Alerts,RSS
Download XML editor
FREE Flash Website
FREE Web Templates

EDUCATION
US Web Design Schools
HTML Certification
JavaScript Certification
XML Certification
PHP Certification
ASP Certification

HOME or Top of Page |  | Printer Friendly
W3Schools is for training only. We do not warrant the correctness of its content. The risk from using it lies entirely with the user. While using this site, you agree to have read and accepted our terms of use and privacy policy. Copyright 1999-2009 by Refsnes Data. All Rights Reserved.