The onmouseover attribute is an inline event handler for the mouseover event. It runs when a pointing device moves the cursor onto the element or one of its child elements.
Pair it with onmouseout for enter/leave. MDN notes that mouseenter is often clearer for “entered this whole box,” because mouseover also fires when moving between parent and children.
Baseline · Widely available.
Not deprecated and not experimental. Stable across modern browsers since about July 2015.
Child boundaries fire mouseover.
Moving from a parent onto a child fires mouseover again (on the child, and bubbled). Prefer mouseenter when you want a single enter for the whole group.
Syntax
HTML Syntax
syntax.html
<element onmouseover="script">
script is JavaScript that runs on enter. Pass event to read event.target and event.relatedTarget. Script alternative: element.addEventListener("mouseover", handler).
Move onto Inner — another mouseover targets the child and bubbles.
Handlers can run many times while staying “inside” the outer box.
Fix: use mouseenter for one enter per whole group, or ignore events when relatedTarget is already inside the parent.
Edge Cases & Pitfalls
Most bugs come from treating every mouseover as a brand-new “entered the component.”
children
Moving onto a child fires mouseover again
MDN: parent/child boundary moves trigger mouseover/mouseout. Prefer mouseenter for a single whole-box enter.
bubbling
mouseover bubbles
A child enter can bubble to ancestors. Check event.target if you only want the outer element.
a11y
Hover-only UI excludes keyboard users
Do not hide essential content behind hover alone. Offer focus or click alternatives for the same information.
touch
Touch has no lasting hover
Phones may synthesize a brief hover on tap. Do not rely on mouseover for critical mobile UX.
pair
Match with mouseout carefully
mouseover/mouseout share child-boundary noise. mouseenter/mouseleave usually do not.
Compatibility
Browser Support
onmouseover is an HTML event handler for the mouseover event in the browser. It is not a Node.js, Deno, or Bun API.
✓ Baseline · Widely available
onmouseover
Widely available since about July 2015. Supported across modern browsers; understand child-boundary behavior before using it for hover menus.
98%Global support (approx.)
Google ChromeAll modern
Full support
Mozilla FirefoxAll modern
Full support
Apple SafariAll modern
Full support
Microsoft EdgeAll modern
Full support
OperaAll modern
Full support
Samsung InternetModern
Full support
Internet ExplorerLegacy support
Supported
onmouseoverWidely supported
Bottom line: Safe to use. For “entered this whole element once,” prefer mouseenter; use mouseover when you intentionally care about child targets.
Remember
Key Takeaways
Role: pointer moved onto the element or one of its children.
vs mouseenter:mouseover reacts to children; mouseenter does not.
relatedTarget: the element the pointer left before enter.
A11y: do not make essential content hover-only.
One line:onmouseover means “entered this element’s area” — including moves onto its children.
Frequently Asked Questions
It is an inline event handler that runs JavaScript when the mouseover event fires — a pointing device moves the cursor onto the element or one of its child elements.
mouseover bubbles and also fires when the pointer moves between a parent and its children. mouseenter fires once when entering the element as a whole and is not affected by moves into descendants. MDN often recommends mouseenter for simple “entered this box” UI.
onmouseover runs when the pointer enters. onmouseout runs when the pointer leaves (including into a child). They are a common enter/leave pair, with the same child-boundary behavior.
Because entering a child still counts as moving onto that child element. A handler on the parent can see bubbled mouseover events from children too.
relatedTarget is the element the pointer left (or null). Combined with target, you can tell where the pointer came from.
No. The mouseover event is Baseline widely available. Prefer mouseenter when you only care about entering the whole element once.