Jump to content

Changing the background color on mouse over


Recommended Posts


If the item will be a link, <a>, then you could use :hover in CSS like so:

<style>
a {
background: blue;
}
a:hover {
background: white;
}
</style>

You could use :hover with other tags, but it won't work in IE, it only recognizes a:hover..

The more compatible method would be javascript + CSS (DHTML I think its called), like so:

<style>
span {
background: blue;
}
.whitespan {
background: white;
}
</style>
</head>
<body>
<span onmouseover="this.className='whitespan'" onmouseout="this.className=''">Text..</span>

Hope this makes sense and helps.. :)

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.


×
×
  • Create New...