Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CSS and HTML mouse out?

Tags:

html

css

ive been googling but cannot seem to find a mouse out method, similar to hover, for css.

Is there one and if so how should it be coded?

like image 471
John Avatar asked Feb 26 '23 18:02

John


1 Answers

You only need the :hover pseudo-class for this, when you mouse out of the element, it'll return to it's default non-:hover state, like this:

.class { color: black; } 
.class:hover { color: red; }

when you hover, the color will be red and when you "mouseout", the color will return to black because it no longer matches the :hover selector. This is the default behavior for all browsers, nothing special you need to do here.

If you want to do something programmatic, you're looking for the mouseout JavaScript event.

like image 120
Nick Craver Avatar answered Mar 08 '23 10:03

Nick Craver