I have some div such as :
<div onmouseover="this.style.background='#CCCCCC'" onmouseout="this.style.background='#FFFFFF'">
So when i go on and out with the mouse, they change colour. Any way to do
Yes:
div{
background-color:#CCC;
}
div:hover{
background-color:#FFF;
}
However, beware that this might fail in some browsers (IE6-) because :hover was at the start only meant to work with links.
:hover on other elements than a.Are you using the <div> as a link? Keep in mind that you can just use an actual anchor, <a>, and make it block level so it can maintain the width of height of your choosing.
a {
display: block;
width: 200px;
background-color: #ccc;
}
a:hover {
background-color: #fff;
}