Image swap

niceextra's picture

They have: 1 posts

Joined: Jan 2009

Does anyone know if there is a way to get an image swap without using Javascript?

In other words, could I set it up so when I hover over a link, an image will change to another one in HTML, CSS, or PHP?

greg's picture

He has: 1,581 posts

Joined: Nov 2005

Neither HTML nor PHP can do this, not at all.

CSS does have hover options, but be careful as issues with images and flicker in some browsers is common.

(all hail Stu Laugh)

He has: 629 posts

Joined: May 2007

Couple of suggestions:

1. Use a background image on the link, and swap it for another on a:hover

2. Use a single background image that has both images in it, and simply change the background position on a:hover to reveal the alternate image

3. Using inline images, use absolute positioning to put an image that's inside the link over the top of the alternate image. Change the visibility of the image inside the link to "hidden" on a:hover to reveal the one underneath.

Not the only possibilities, but hopefully enough to get you started.

Cordially, David
delete from internet where user_agent="MSIE" and version < 8;

Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.