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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T15:44:03+00:00 2026-05-27T15:44:03+00:00

I thought the following selector would only match example b . Can someone explain

  • 0

I thought the following selector would only match example b. Can someone explain to me a little more about how CSS paths work?

body div span a{
    background:#000;
    color:#fff;
}
<body>
    <div><span><span><a href="#">example a</a></span></span></div>
    <div><span><a href="#">example b</a></span></div>
    <span><div><span><a href="#">example c</a></span></div></span>
</body>

A visual example or a more elaborated tree/paths with “this will be affected”, “this won’t” would be extremely helpful to me. A link to a good guide could also be interesting.

  • 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-27T15:44:03+00:00Added an answer on May 27, 2026 at 3:44 pm

    See the W3C specification for more information.

    To simplify your example, a selector div a { } will match any <a> tag which descends from a <div> tag, regardless of how many levels of ancestry separate the two tags.

    That is, div a { } will match any of the following:

    <div> <a>...</a> </div>
    
    <div> <h2> <a>...</a> </h2> </div>
    
    <div> <h2> <span> <a>...</a> </span> </h2> </div>
    

    If you want to match an <a> contained directly within a <div> with no other tags separating them, you need to use div > a, which matches only <a> tags that are direct descendants of a <div> tag.

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

Sidebar

Related Questions

I've got an asp.net control inside a masterpage, so I thought the following selector
I thought about the following question about computer's architecture. Suppose I do in Python
How can I get the following test to pass with NHibernate? I thought it
This is what I thought would be a simple select clause, however the following
I can't really get why the following selector works as expected (i.e. get the
The following code is failing becuase of the $(id + _pan) selector. I thought
I thought the following task would be seemingly easy to code, but I have
I have a question about overriding auto-generated accessor methods. The following would not work
I thought the following line of code should work fine: $(.1).attr('href', '#Home'); Right? But
Never thought I'd have this problem :) The following snippet of code works in

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.