I’m currently using this current HTML markup with Javascript to create text links with a inline image that “rolls over” on the text hover.
<div><a id="link" href="page.html"
onmouseover="rollover(this.id,'over');"
onmouseout="rollover(this.id,'out')"
>Link</a><img id="linkButton" src="image.gif" /></div>
It’s important that the image is inline so I can easily create new text links with varying lengths of text.
I want to try and get this done without Javascript, and using a single image containing the over and out states of the rollover, so probably using the background position trick.
You need to use
background-image(or justbackground) in CSS. Here is an example http://www.webvamp.co.uk/blog/coding/css-image-rollovers/The key is using pseudo classes on the link element. Eg:
You can also use
inline-blockso that theaisn’t completely a block element. You may want to set a width and a height to it. Keep in minddisplay:inline-blockdoesn’t work that great in IE7, if you still need to support that.Here’s some additional tips on using CSS Sprites