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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T05:18:41+00:00 2026-05-24T05:18:41+00:00

When I hover over a div or class with an id of a, can

  • 0

When I hover over a div or class with an id of “a”, can I get the background color of a div or class with the id of “b” to change?

  • 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-24T05:18:43+00:00Added an answer on May 24, 2026 at 5:18 am

    Yes, you can do that, but only if #b is after #a in the HTML.

    If #b comes immediately after #a: http://jsfiddle.net/u7tYE/

    #a:hover + #b {
        background: #ccc
    }
    
    <div id="a">Div A</div>
    <div id="b">Div B</div>
    

    That’s using the adjacent sibling combinator (+).

    If there are other elements between #a and #b, you can use this: http://jsfiddle.net/u7tYE/1/

    #a:hover ~ #b {
        background: #ccc
    }
    
    <div id="a">Div A</div>
    <div>random other elements</div>
    <div>random other elements</div>
    <div>random other elements</div>
    <div id="b">Div B</div>
    

    That’s using the general sibling combinator (~).

    Both + and ~ work in all modern browsers and IE7+

    If #b is a descendant of #a, you can simply use #a:hover #b.

    ALTERNATIVE: You can use pure CSS to do this by positioning the second element before the first. The first div is first in markup, but positioned to the right or below the second. It will work as if it were a previous sibling.

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

Sidebar

Related Questions

With the following html, when I hover over child, I get a green background
How can a get the number by hovering mouse over the div? HTML <div
I understand #div:hover:not(.class) works. However, how can I achieve a "hover" effect for a
I have css hover over images for my tabs and I'm trying to get
In SharePoint 2007, there's a top nav that the user can hover over, which
You can see the implementation here . When you hover over any of the
How can i hover over an item in a list of items and the
What I'm trying to do is to change the background color on the whole
I want to hover over a table element, and display a popup box in
I have a simple search box that it hidden until hover(over) and hides again

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.