Go to main content
Bypass navigation bar HTML Reference HTML Tags HTML Tutorials
Bypass language selection
Bypass location bar

Location: Home > HTML Reference > Events in HTML

Bypass main content

Events in HTML

Events are a feature of HTML documents (present in other programming languages too) that allow authors to add interactivity between the website and it's visitors, by executing client-side programs when the visitor (or other program) performs an action. For example, the author can make a paragraph change the color of its text when the user puts the mouse pointer over it.

As well as attributes, events can be easily defined in an element's start tag, with the same format:

<tag_name event_name="code">

The content of the event is the code to be executed, and must be created using a cleint-side language (e.g., JavaScript) that must be supported by the browser. In the next example, we define a paragraph that changes the color of its text to red when the mouse passes over, and to black when it goes away.

Code
<p onmouseover="this.style.color='red'" onmouseout="this.style.color='black'">This is a changing color text. Try it!</p>
View

This is a changing color text. Try it!

List of events

Below there is al list of all events available for the HTML 4.01 and XHTML 1.0 standards.

Note, that not all elements support every event in this list. To know which events are supported by a specific element, refer to the HTML tags reference and follow its link.

Links and logos|Contact|Beyond HTML|Tools and resources|Sitemap|Webmaster