Considering logo is more like content (than decoration) on a webpage, I find this markup suitable for my website:
<h1 id="logo">
<a href="http://stackoverflow.com">
<img src="logo.png" alt="Stack Overflow">
</a>
</h1>
Given the case, how should I go about creating a rollover/hover effect such that a different logo image is displayed on hover? (E.g. the actual logo is black-and-white; on hover, the colorful logo image is shown.)
Doing something like this feels stupid (but I have no better ideas in mind):
HTML:
<h1 id="logo">
<a href="http://stackoverflow.com">
<img id="logo-img1" src="logo1.png" alt="Stack Overflow">
<img id="logo-img2" src="logo2.png" alt="Stack Overflow">
</a>
</h1>
CSS:
#logo #logo-img2 {
display: none;
}
#logo:hover #logo-img1 {
display: none;
}
#logo:hover #logo-img2 {
display: inline;
}