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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T07:16:48+00:00 2026-05-27T07:16:48+00:00

If this has been asked before I sincerely apologize. After around half an hour

  • 0

If this has been asked before I sincerely apologize. After around half an hour of searching I cannot seem to find one “best answer,” and most solutions I have come across seem to involve JavaScript. While I am not totally opposed to JavaScript – HTML, CSS, and PHP are definitely my stronger skillsets. If this cannot be done without using JavaScript, I will probably need some serious baby talk. Here’s my question:

I would like to change the background image of an one element as the hover state of an entirely separate element. Here is an example of how I would like this to work:

.some_element:hover {
    #some_unrelated_div {
         background-image: url('path/to/img.jpg');
    }
}

I hope that conveys a clear enough message of my ideal solution. Thanks guys.

  • 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-27T07:16:49+00:00Added an answer on May 27, 2026 at 7:16 am

    CSS cannot accomplish this. CSS is meant to be read line-by-line and very quickly, so logic isn’t something that should be done in CSS.

    That being said, you can do this:

    .some_element:hover #child_div {
      background-image: url('path/to/img.jpg');
    }
    

    Iff your HTML is similar to this:

    <div class="some_element">
      <div id="child_div">Hello</div>
    </div>
    

    This works because the selector matches the #child_div belonging to a :hovered .some_element.

    If you plan on using jQuery, this skeleton code will accomplish the job:

    $('#trigger').hover(function() {
      $('#some_element').css('background-image', 'url("foo.png")');
    }, function() {
      $('#some_element').css('background-image', 'url("bar.png")');
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm sure this has been asked before, but I can't seem to find it
I'm sure this has been asked before, but I can't seem to find the
I'm pretty sure this has been asked before but I can't seem to find
Sorry if this has been asked before, I can't seem to find anything. I'm
I'm sure this has been asked before, but as I can't seem to find
I suspect this has been asked before, but can't seem to find a question
If this has been asked before please forgive me, I could not find it.
I'm sure this has been asked before, but I can't find it. What are
I apologise if this has been asked before but I can't find the info
Maybe this has been asked before, but I couldn't find it. My question is

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.