HTML and CSS Reference
meaning that they can happen at any time. They are actions that are initiated by a user
visiting a Web page; for example, if the user submits a form or moves the mouse over a
link or an image, he or she might trigger an event. When an event occurs, your browser
has some default actions it takes; for example, if you click on a link, it opens up the loca-
response. The event itself may be blur, click, change, keystroke, and so on. We have seen
many examples using event handlers in previous examples. This chapter explains how
each of the event handlers responds when events occur on different objects.
scripting model, and the DOM 2 model. In this chapter we discuss the inline model and
way events are handled by the W3C DOM Level 2 model and its pros and cons.
This is the oldest and easiest way to handle events. With the inline model, the event han-
dlers are attributes of an HTML tag and are used to handle the event for which they are
named. For example the onClick handler will handle the click event, the onSubmit handler
will handle the submit event, and so on. Although a very popular way of dealing with
is not separated from the HTML markup. The inline model will be used here to show you
what the many event handlers do, and how they affect the objects in a document. Later in