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 648031
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T21:47:17+00:00 2026-05-13T21:47:17+00:00

When I have an <a> tag set to a specific image background like this:

  • 0

When I have an <a> tag set to a specific image background like this:

HTML:
<a href="..." title="click here">Click Here</a>

CSS:
a {
  background: transparent url(button.png);
}

and I want the background to change whenever a user hovers over the spot, like this:

CSS:
a {
  background: transparent url(button_HOVER.png);
}

The hover background image flickers (takes about 1-2 seconds until it fully loads) when a user hovers over the link.

I could save the file as GIF and minify its size and loading time, but that would harm my specific image tremendously (it’s big and highly graphical).

That’s why I was looking for a better solution, such as perhaps counting on the browsers ability to cache images. Hence would I apply a style to a button like this:

CSS:
a {
  background: transparent url(button_HOVER.png);
  background: transparent url(button.png);
}

So that the image button_HOVER is first cached. It has seemingly affected the “flickering”, but not completely. I thought of maybe creating a hidden tag with the HOVER image, so that maybe the result would be different.

Do you think there’s a better way to solve it? (I emphasize I want to keep the file as PNG, it weighs 6-7k). Is my method efficient?

  • 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. Editorial Team
    Editorial Team
    2026-05-13T21:47:18+00:00Added an answer on May 13, 2026 at 9:47 pm

    Your solution would be to put both images (hover and active) in the same image file. Positioned on top of each other. Also known as Image Sprites. The browser will load the entire image file. On hover, you just change the background position.

    Assuming the active image is at the top, and the hover image is positioned directly below that..your css code would be something like:

    a.link {
      width:70px;
      height:24px;
      background: url(image.png) top no-repeat;
    }
    a.link:hover {
      background-position: bottom;
    }
    

    Notice background-position. Here I use top and bottom. You can specific exactly in pixels too. The entire image in this example would have a width of 70pixels and height of 48pixels. Some sites put all their small icons into one image. Loads altogether, save on requests too. 🙂

    No need for preload scripts in this case.

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

Sidebar

Related Questions

I have a div tag styled through CSS. I set the padding to 10px
If I have a script tag like this: <script id = myscript src =
I have a .tag file that requires a JavaScript library (as in a .js
I have three tables tag , page , pagetag With the data below page
I have an img tag in my webapp that uses the onload handler to
I have a Div Tag which contains 4 child Div Tags <Div id=Parent> <div
I have a <table/> in a ViewUserControl that I have given the tag a
I am hacking up a tagging application for emacs. I have got a tag
I have a list string tag. I am trying to initialize a dictionary with
I have to add either an embed tag for Firefox or an object tag

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.