HTML Events


There is not much to say about HTML events without mentioning JavaScript, the engine responsible for all the action behind the scene. This page is thus limited merely to listing the most frequently used HTML events. It is worthwhile mentioning that an HTML element can, and frequently does, contain more than one event attribute.

bulletWindow events

They are triggered by the browser when it opens or closes. The action attributes are: onload, onunload.

bulletForm element events

These are responses to user-initiated events, such as change of a list-item, submission/reset button click, checkbox selection, pointing at an image etc. The main events are: onchange, onsubmit, onreset, onselect, onblur, and onfocus.

bulletKeyboard events

As the title suggests, they occur when the user presses or releases the keyboard key. Occasionly it is necessary to run a script when the keygoes first down and then up. This makes three important events: onkeydown, onkeyup, and onkeypress.

bulletMouse events

The last set of events is mouse-initiated, and it consists of: onclick, ondblclick, onmousedown, onmousemove, onmouseout, onmouseover, onmouseup.


You can get an idea about the event dynamic by exercising examples like this one.

<html xmlns="" 
   lang="en" xml:lang="en">
            width:100px; height:80px; padding-top:20px;
            font-weight:bold; text-align:center;
            color:blue; background-color:green;
   <body onload="window.alert('Form is loaded')"
         onunload="window.alert('Form is unloaded')">  

   <div class="box" 
        onmouseup="window.alert('Mouse button released!')"
        onclick="window.alert('You clicked the box!')"
         Click me!


C. D. Knukles and D. S. Yuen: Web Applications, Concepts & Real World Designs. Wiley, 2005

HTML 4.0 Event Attributes, W3 Schools, 2006

Web Design Group HTML Help and Web Authoring Reference, Web Design Group , 2006

Markup Validation Service, World Wide Web Consortium , 2006