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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T16:16:54+00:00 2026-05-28T16:16:54+00:00

I apologize in advance if I am asking asking question with impossible answer. But

  • 0

I apologize in advance if I am asking asking question with impossible answer. But I just thought it was worth asking, maybe somebody knows how to achieve what I am asking for.

I have image on the page like this ( image url is generated dynamically on the server by PHP ):

<img src="/images_BIG/image_12345.jpg" />

Now – I would love to use only CSS media queries to change this image URL, let’s say to this ( when browser viewport width is smaller than e.g. 800px ):

<img src="/images_SMALL/image_12345.jpg" />

I know this can be done by PHP (detecting mobile browsers and return appropriate URL) or use Javascript to change URL on the fly. But is this possible with CSS3 ? I am aiming only on HTML5 browsers so no need to care about IE.

Thank you for any thoughts and help in advance.

  • 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-28T16:16:55+00:00Added an answer on May 28, 2026 at 4:16 pm

    Wrap the image in a div. Use mobile first, so that it only downloads the small version of the image on small screens. On bigger screens, the image will be hidden and a background image will be there instead.

    The two downsides – a non-semantic wrapping div, and the need to specify the height and width of the div. The upside is that you get the foreground image in the HTML.

    The HTML

    <div class="imgContainer"><img src="/images_SMALL/image_12345.jpg" /></div>
    

    The CSS

    // for screens bigger than 800px
    @media screen and (min-device-width:800px) {
      div.imgContainer {
        background-image:url(../images_BIG/image_12345.jpg);
        background-size:100px;
        width:100px;
        height:100px;
      }
      img {
        display:none;
      }
    }
    

    EDIT
    Based on your comment above, I would say add the wrapping div and set its background image with jQuery.

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

Sidebar

Related Questions

I apologize in advance because this is somehow a silly question, but I just
I apologize in advance for this somewhat ignorant question, but I have researched this
I apologize in advance about asking a so similar question, but i'm rather frustrated,
I apologize in advance for asking this question, I know similar questions have already
I apologize in advance for asking such a stupid question, but how do I
I apologize in advance for the open-ended question. I tried searching, but wasn't sure
I apologize in advance for a newbie question, but why do I get Access
I apologize in advance if this is a newb question, but what are some
This question might be very abstract, so apologize in advance. I have a log
Apologies in advance for asking a (seemingly obvious) question. I haven't found an answer

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.