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

  • SEARCH
  • Home
  • 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 3216090
In Process

The Archive Base Latest Questions

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

I am replacing most inline images on my sites with a sprite. The sprite

  • 0

I am replacing most inline images on my sites with a sprite.

The sprite class would contain some basic css:

.sprite{
background-image:url(...);
background-position:...;
width: 16px;
height:16px;
}

I saw that nesting div inside of an anchor tag is not a good idea.

<a><div class="sprite"></div></a>

I’ve tried to add sprites to span elements instead.

<a><span class="sprite"></span></a>

But the span elements do not expand to the width and height that I set.
It would be really useful to be able to use span elements to replace image tags with a sprite.
I could add a blank gif image into the span element to expand it. But that would defeat the reason why I want to use sprites (to reduce the number of http requests).

Using div elements inside an anchor tag is not correct.

So how can I use sprites inside an anchor element?

And there also is always the problem of aligning the div. If an image is centered in another element, how do I replace it with a sprite?

  • 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-17T15:15:14+00:00Added an answer on May 17, 2026 at 3:15 pm

    You need to declare display: block; on your span elements which are by default inline elements. Something like:

    .sprite{
        display: block;
        background-image:url(...);
        background-position:...;
        width: 16px;
        height:16px;
    }
    

    That should make the span elements expand to your desired width/height.

    Hope this helps !

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

Sidebar

Related Questions

From your experience, what would be the most suitable CSS solution for replacing the
My customer is replacing MS Office with OpenOffice in some workstations. My program export
I'm replacing some text with cufon on my page and I'm using jquery stylish
how could I go about replacing a form submit button with a image submit
In most of the methods I use that return some kind of collection I
What is the most efficient way of retrieving and replacing the last line of
I have tried every possible combination of methods for replacing an image but have
So in this URL: http://twitpic.com/2paihn The Twitpic ID is: 2paihn And the actual image
What would be an efficient way of replacing a fixed position substring with another
I've spent most of the day making what are basically some housekeeping changes to

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.