HTML onmouseout Event Attribute

Description

The event attribute onmouseout allows you to set the script to fire when the mouse moves outside the element.

Syntax

<element onmouseout="script">

Values

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

Example

<!DOCTYPE html> 
  <html> 
    <head>
      <title>onmouseout event</title> 
      <style> 
      img {
        width: 60px;
        height: 60px;
      }
      </style> 
    </head> 
    <body> 
    <p>To demonstrate the onmouseout event attribute, hover over the image:</p>
    <img onmouseover="enlarge(this)" onmouseout="normal(this)" src="2.png" alt="CSS"> 
    <p>After you remove the mouse pointer from the image, a script will be run that is set to the onmouseout event attribute, which will return the original image size.</p>
<script> 
function enlarge(x) {
  x.style.height="120px"; 
  x.style.width="120px";   
} 
function normal(x) {
  x.style.height="60px"; 
  x.style.width="60px";   
} 
</script> 
  </body> 
</html>

Supported Tags

All HTML elements except:
<base>, <bdo>, <br>, <head>, <html>, <iframe>, <meta>, <param>, <script>, <style> and <title>

Browser Support

Desktop
Explorer Edge Chrome Firefox Opera Safari
YesYesYesYesYesYes
Tablets / Mobile
Android Chrome Firefox Opera Safari Samsung
YesYesYesYesYesYes