Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 59483
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T18:00:45+00:00 2026-05-10T18:00:45+00:00

When setting up a rollover effect in HTML, are there any benefits (or pitfalls)

  • 0

When setting up a rollover effect in HTML, are there any benefits (or pitfalls) to doing it in CSS vs. JavaScript? Are there any performance or code maintainability issues I should be aware of with either approach?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-10T18:00:45+00:00Added an answer on May 10, 2026 at 6:00 pm

    CSS is fine for rollovers. They’re implemented basically using the :hover pseudo-selector. Here’s a really simple implementation:

    a{     background-image: url(non-hovered-state.png); } a:hover{     background-image: url(hovered-state.png); } 

    There are a few things you need to be aware of though:

    • IE6 only supports :hover on <a> tags
    • Images specified in CSS but not used on the page won’t be loaded immediately (meaning the rollover state can take a second to appear first time)

    The <a>-tags-only restriction is usually no problem, as you tend to want rollovers clickable. The latter however is a bit more of an issue. There is a technique called CSS Sprites that can prevent this problem, you can find an example of the technique in use to make no-preload rollovers.

    It’s pretty simple, the core principle is that you create an image larger than the element, set the image as a background image, and position it using background-position so only the bit you want is visible. This means that to show the hovered state, you just need to reposition the background – no extra files need to be loaded at all. Here’s a quick-and-dirty example (this example assumes you have an element 20px high, and a background image containing both the hovered and non-hovered states – one on top of the other (so the image is 40px high)):

    a{     background-image: url(rollover-sprites.png);     background-position: 0 0; /* Added for clarity */     height: 20px; } a:hover{     background-position: 0 -20px; /* move the image up 20px to show the hovered state below */ } 

    Note that using this ‘sprites’ technique means that you will be unable to use alpha-transparent PNGs with IE6 (as the only way IE6 has to render alpha-transparent PNGs properly uses a special image filter which don’t support background-position)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 163k
  • Answers 163k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer For compression, I'd consider gzip, bzip2 and LZMA (this is… May 12, 2026 at 12:12 pm
  • Editorial Team
    Editorial Team added an answer I assume every page, except for the first, will have… May 12, 2026 at 12:12 pm
  • Editorial Team
    Editorial Team added an answer The likely cause of your ConcurrentModificationException is that you are… May 12, 2026 at 12:12 pm

Related Questions

When setting up a new virtual directory for hosting a SOAP web service in
When setting up a Visual Studio .NET solution with many projects, do you find
When setting up a new ASP.NET MVC Web Application, the default connection string inside
I have encountered a problem that I have not come accross yet when setting

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.