Favorites

HTML onmouseenter Event Attribute

☕
Enjoying this site?

Help keep it running with a small coffee donation. Every bit of support is appreciated!

Buy us a coffee
onmouseenter
HTML Event AttributeThis event attribute is supported by all modern browsers.
Updated 22nd November 2026

Description

The onmouseenter event attribute runs a script when the mouse pointer moves onto an element.

It is similar to onmouseover, with two important differences: mouseenter does not bubble, and it does not fire again when the pointer moves between the element and its children. mouseover fires each time the pointer enters the element or any of its descendants. This makes onmouseenter, together with onmouseleave, the simpler choice for hover effects on elements that contain other elements.

For a pure visual effect, the CSS :hover pseudo-class is usually enough. For pens and touch as well as mice, use onpointerenter.

Syntax

<element onmouseenter="script">

Values

  • scriptThe name of the script to use when the event has been triggered.

Example

<!DOCTYPE html>
<html>
<head>
<title>onmouseenter event</title>
<style>
#box {
padding: 30px;
background: #dde3ff;
}
#box span {
display: inline-block;
padding: 10px;
background: #4361ee;
color: #fff;
}
</style>
</head>
<body>
<div id="box" onmouseenter="log('mouseenter')" onmouseover="log('mouseover')">Move the mouse over this box <span>child</span></div>
<ul id="log"></ul>
<script>
function log(text) {
var li = document.createElement("li");
li.textContent = text;
document.getElementById("log").appendChild(li);
}
</script>
</body>
</html>
Open in editor

Browser Support

The following information will show you the current browser support for the HTML onmouseenter event attribute. Hover over a browser icon to see the version that first introduced support for this HTML event attribute.

This event attribute is supported by all modern browsers.

Desktop

Chrome
Edge
Firefox
Opera
Safari

Tablets & Mobile

Chrome Android
Firefox Android
Opera Android
Safari iOS
Samsung Internet
Android WebView
-
Supported Unknown Not supported
☕
Enjoying this site?

Help keep it running with a small coffee donation. Every bit of support is appreciated!

Buy us a coffee