HTMLforall

  HTML | PHP | Forum

HTML Events

New to HTML 4.0 was the ability to let HTML events trigger actions in the browser, like starting a JavaScript when a user clicks on an HTML element. Below is a list of attributes that can be inserted into HTML tags to define event actions.

Window Events

Only valid in body and frameset elements

Attribute Value Description
onload script Script to be run when a document loads
onunload script Script to be run when a document unloads

Form Element Events

Only valid in form elements.

Attribute Value Description
onchange script Script to be run when the element changes
onsubmit script Script to be run when the form is submitted
onreset script Script to be run when the form is reset
onselect script  Script to be run when the element is selected
onblur script  Script to be run when the element loses focus
onfocus script  Script to be run when the element gets focus


Keyboard Events

Not valid in base, bdo, br, frame, frameset, head, html, iframe, meta, param, script, style, and title elements.

Attribute Value Description
onkeydown script  What to do when key is pressed
onkeypress script  What to do when key is pressed and released
onkeyup script  What to do when key is released


Mouse Events

Not valid in base, bdo, br, frame, frameset, head, html, iframe, meta, param, script, style, and title elements.

Attribute Value Description
onclick script  What to do on a mouse click
ondblclick script  What to do on a mouse doubleclick
onmousedown script  What to do when mouse button is pressed
onmousemove script  What to do when mouse pointer moves
onmouseover script What to do when mouse pointer moves over an element
onmouseout script What to do when mouse pointer moves out of an element
onmouseup script  What to do when mouse button is released

 

Home

Learn HTML
HTML Tutorial

HTML Reference
HTML by function
HTML by Alphabet

HTML events
HTML attributes
HTML color names

<!--...-->
<!DOCTYPE> 
<a>
<abbr>
<acronym>
<address>
<applet>
<area>
<b>
<base>
<basefont>
<bdo>
<big>
<blockquote>
<body>
<br>
<button>
<caption>
<center>
<cite>
<code>
<col>
<colgroup>
<dd>
<del>
<dfn>
<dir>
<div>
<dl>
<dt>
<em>
<fieldset>
<font>
<form>
<frame>
<frameset>
<h1> to <h6>
<head>
<hr>
<html>
<i>
<iframe>
<img>
<input>
<ins>
<isindex>
<kbd>
<label>
<legend>
<li>
<link>
<map>
<menu>
<meta>
<noframes>
<noscript>
<object>
<ol>
<optgroup>
<option>
<p>
<param>
<pre>
<q>
<s>
<samp>
<script>
<select>
<small>
<span>
<strike>
<strong>
<style>
<sub>
<sup>
<table>
<tbody>
<td>
<textarea>
<tfoot>
<th>
<thead>
<title>
<tr>
<tt>
<u>
<ul>
<var>

 

Copyright 2005-8 Sunilcare.  All Rights Reserved.
Comments or suggestions? Contact us.About us