What Is an HTML Hover?

Eugene P.

Within a web browser that is displaying a HyperText Markup Language (HTML) document, an HTML hover is an action or event that is generated through user input. By strict definition, an HTML hover is what happens when the mouse cursor on a screen comes to rest on an element within the web page, triggering a hover event that can be responded to by code placed inside the web page. The actual effect can be anything from displaying some navigational text to changing an image to make it appear highlighted, or even modifying some separate property on the web page. Some web browsers and operating systems define a hover event a little differently, so selections using the tab key on a keyboard also will be considered hovering. HTML hover events are usually capture by cascading style sheet (CSS) code, JavaScript® functions or a combination of both, because basic HTML has no facility to interact directly with a hovering cursor.

A hover event that can be responded to by code placed inside the web page.

Most computer operating systems that accept user input actually break down each seemingly simple action into a sequence of stages, or events. Web browsers must be able to interpret and respond to these events so users can interact with a web page. These events are generated by the computer system in response to a user action, passed to the web browser, and then made available to any active programs that are listening for the events attached to the HTML page.

When a mouse cursor passes over an element in an HTML document, it actually generates at least three separate events. The first is when the mouse initially comes into contact with the element, which is known as an enter or onMouseEnter event. The last event generated when the mouse leaves the element is called an exit or onMouseExit event. The period of time in which the mouse is sitting inside the element between these two events is known as hovering, and it generates an HTML hover event. One thing to note about hovering is that a mouse does not always have to sit perfectly still to be considered hovering, the event can be automatically triggered just by entering the elements space.

Navigation assistance is one common use for an HTML hover event, popping up some informational text at the location of the mouse cursor when a link or image is passed over. It also can used to provide short textual definitions of words in a document. More often, it is used for aesthetic purposes, such as making graphical dials or arrows animate when the mouse gives them focus. Although there are many security precautions to prevent it, particularly malicious code can sometimes use an HTML hover event over a blank space on a web page to cause pop-up windows to appear outside the web browser.

You might also Like

Discuss this Article

Post your comments
Forgot password?