HTML events are "things" that happen to HTML elements.
An HTML event can be something the browser does, or something a user does.
Here are some examples of HTML events:
Often, when events happen, you may want to do something.
With single quotes:
With double quotes:
In the following example, an
onclick attribute (with code), is added to a
In the next example, the code changes the content of its own element (using
Here is a list of some common HTML events:
|onchange||An HTML element has been changed|
|onclick||The user clicks an HTML element|
|onmouseover||The user moves the mouse over an HTML element|
|onmouseout||The user moves the mouse away from an HTML element|
|onkeydown||The user pushes a keyboard key|
|onload||The browser has finished loading the page|
Event handlers can be used to handle, and verify, user input, user actions, and browser actions:
You will learn a lot more about events and event handlers in the HTML DOM chapters.