Using the :hover selector

Description

The :hover selector matches element that the user's mouse hovers over.

The selected elements change as the user moves their mouse around the document.

Example

The following code uses the :hover Selector.


<!DOCTYPE HTML>
<html>
<head>
<style type="text/css">
:hover {<!--  w ww  .jav a  2  s.  co m-->
  border: thin black solid;
  padding: 4px;
}
</style>
</head>
<body>
  <a href="http://java2s.com">Visit the website</a>
  <p>
    I like <span>HTML</span>.
  </p>
  <a href="http://w3c.org">Visit the W3C website</a>
</body>
</html>

Click to view the demo





















Home »
  HTML CSS »
    CSS »




CSS Introduction
CSS Background
CSS Border
CSS Box Layout
CSS Text
CSS Font
CSS Form
CSS List
CSS Selectors
CSS Others
CSS Table