You solve this by re-thinking your options.
You create a defined area with a <a>
with display:block;
or <div>
and use overflow hidden;
to hide overflow and position:relative;
.
Then you place your <img>
image sprite inside absolutely positioned, which is possible since you positioned the parent.
Then use :hover
on the image to change position.
Now your sprite is based on an img tag, so you can use your alt
text.
Following example is based on a Facebook sprite with two versions of the icon on top of each other, each 50px by 50px, total height of image being 100px:
<!DOCTYPE html>
<html>
<head>
<style>
.icon {
display:block;
position:relative;
width:50px;
height:50px;
border:1px solid red;
overflow:hidden;
}
#fb {
position:absolute;
top:0;
left:0;
}
#fb:hover {
position:absolute;
top:-50px;
left:0;
}
</style>
</head>
<body>
<a href="https://facebook.com" class="icon" title="Facebook">
<img src="sprite-facebook.png" id="fb" width="50" height="100" alt="Facebook">
</a>
</body>
</html>