Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Best way to replace menu images on hover

Featured Replies

My menu is made up of images - not background images, just images nested inside an a element. When the user hovers over an image, I want the image to be replaced. Each menu item has a different image and needs a different image on hover. How would you recommend I do this so there is no delay in loading the image when the user first hovers?

 

Here is my html:

 

<ul id="navbar" class="fr">
           <li><a href=""><img src="images/coloured_in_nav/home.png"/></a></li>

           <li><a href=""><img src="images/coloured_in_nav/web.png"/></a></li>

           <li><a href=""><img src="images/coloured_in_nav/print.png"/></a></li>

           <li><a href=""><img src="images/coloured_in_nav/other.png"/></a></li>
           <li><a href=""><img src="images/coloured_in_nav/about.png"/></a></li>
                  </ul>

Let's go back to the beginning. All images that are not part of the content should be inserted as background-images. Without exception. A good rule of thumb for determining whether an image is content or decoration is to examine (or imagine) your page as unstyled HTML, and ask yourself if that image belongs on the page.

 

All navigation should have link text. Again, without exception. If you want to replace that text with an image, set it as a background-image and give the text a very large negative text-indent in ems. That ensures that your text is still accessible to screen readers, and specifying it in ems rather than pixels means it doesn't sidle back into view if the text size is increased.

  • Author

Let's go back to the beginning. All images that are not part of the content should be inserted as background-images. Without exception. A good rule of thumb for determining whether an image is content or decoration is to examine (or imagine) your page as unstyled HTML, and ask yourself if that image belongs on the page.

 

All navigation should have link text. Again, without exception. If you want to replace that text with an image, set it as a background-image and give the text a very large negative text-indent in ems. That ensures that your text is still accessible to screen readers, and specifying it in ems rather than pixels means it doesn't sidle back into view if the text size is increased.

 

Thanks for this. I haven't learned any real thick and fast rules so I really appreciate learning golden rules such as these. I have changed them now to background images.

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.