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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T03:21:02+00:00 2026-06-11T03:21:02+00:00

I have four <div> box each are placed one inside another and first box

  • 0

I have four <div> box each are placed one inside another and first box is define as class="a" and rest are define as class="b" now What I want to do with the help of class="b" I want to set third box background-color:red so How it can be done with only class="b" no different class or id I want.Will it be possible or not?

<div class="A">
<div class="B">
<div class="B">
<div class="B"></div>
    </div>
</div>
</div>

and if the case like this

<div class="A">
    <div class="B"></div>
    <div class="B"></div>
    <div class="B"></div>    

    </div>

Then how can I make third box red with help of class only
JSFIDDLE and
2nd JSFIDDLE
​

  • 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-06-11T03:21:04+00:00Added an answer on June 11, 2026 at 3:21 am

    Yes it is possible.

    Use the CSS Selector this way:

    div.B .B .B
    {
        background-color:red;
    }​
    

    Updated Fiddle: http://jsfiddle.net/yH8e3/3/

    For the second case, you need to use :nth-child selector:

    .A .B:nth-child(3)
    {
        background-color:red;
    }​
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have four div in one parent and each contains one image. i want
I want to position four div s relative to another. I have a rectangle
If i have the following markup; <div id=container> <div id=box> <div id='sameHeight'>One<br>two<br>three</div> <div id='sameHeight'>four</div>
I have four Div's one after the other inside a main div and aligned
I have four <div> in one page. I want to display 25 records on
I have four divs contained in another div, and I want the four inner
I have four divs each with the same ID but different class. <div id=inner
Alright, let's say that I have the following markup: <div class=ticker> <p>News Item One.
I have four input fields in a div. The first two are for first
I have four text boxes all with similar code. Each one on hover fades

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.