HTML Element Style How to - Create hover style by default








Question

We would like to know how to create hover style by default.

Answer


<!DOCTYPE html>
<html>
<head>
<style type='text/css'>
ul li:first-child, ul li:hover {<!--from  ww w. j ava 2  s .c om-->
  color: blue;
}

ul li:first-child:hover {
  color: black;
}
</style>
</head>
<body>
  <ul>
    <li>one</li>
    <li>two</li>
    <li>three</li>
  </ul>
</body>
</html>

The code above is rendered as follows: