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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T06:21:25+00:00 2026-05-14T06:21:25+00:00

I just came up with this, it seems to work in all modern browsers,

  • 0

I just came up with this, it seems to work in all modern browsers, I just tested it then on (IE8/compatibility, Chrome, Safari, Moz)

HTML

<img id="my_image" alt="my text" src="images/small_transparent.gif" />

CSS

#my_image{
  background-image:url('images/my_image.png');
  width:100px;
  height:100px;}

Pro’s:

  • image alt text is best-practice for accessibility/seo
  • no extra HTML markup, and the css is pretty minimal too
  • gets around the css on/images off issue where “text-indent” techniques hide text from low bandwidth users

The biggest disadvantage that I can think of is the css off/images on situation, because you’ll only send a transparent gif.

I’d like to know, who uses images without stylesheets? some kind of mobile phone or something?

I’m making some sites for clients in regional Australia (hundreds of km from the nearest city), where many users will be suffering from dial-up connections, and often outdated browsers too, so the “images off” issue is an important consideration.

are there any other side effects with this technique that I haven’t considered?

edit: Just wanted to add the extra info that I’d use this over a normal image tag because

A. I can use css-sprites

B. I can generate css with php that alternates background-image sources between different sub-domains using a single array

C. I like the way that resizing the image now doesn’t stretch or distort it so it behaves like everything else on the page.

  • 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-14T06:21:25+00:00Added an answer on May 14, 2026 at 6:21 am

    What is wrong with normal image tags? img tags are meant to be used when your content has images in it, and CSS shouldn’t take any part in what the actual content is. On the other hand, presentational images should be set as background-images to divs and such and then handled via CSS so that they don’t interfere with the content and structural markup.

    There’s no scenario where you’d need to do something like that.

    If you want an image replacement technology that degrades gracefully when CSS is off, you can use the old faithful text-indent technique:

    #element {
        width: 100px;
        height: 100px;
        background: image(pic.jpg);
        text-indent: -9999px;
    }
    
    <div id="element">This text will show if CSS is off, otherwise an image is displayed.</div>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Just came across this by Chris Coyier - http://css-tricks.com/examples/CSSTabs/ Can anyone explain me, how
I've just came across this on GitHub. ($config === NULL) and $config = Kohana::config('email');
I'm new to C programming and I just came across this program and got
I just came a cross this nice code that makes this scatter matrix plot:
I am studying REST with JAX-RS, and this doubt just came to my mind:
I came across this term - Quine (also called self-reproducing programs). Just wanted to
I came across this link flying twitter bird , was just wondering , how
I just visited this website , where I came acros this glowing menu (bottom
Just came across an issue with my Wordpress template that I can't figure out.
Came into the office today to do some more work on my nearly completed

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.