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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T21:45:24+00:00 2026-06-11T21:45:24+00:00

For instance, div > p can be used to select all <p> elements that

  • 0

For instance, div > p can be used to select all <p> elements that are direct children of a <div> element. Is it valid to use div > p > span to select a <span> elements that has a <p> parent and a <div> grandparent?

What about other operators in CSS selectors? Is it valid to use ‘+’ in div + p + span or ‘,’ in div, p, span?

How about combining different selectors? Like div + p > span?

  • 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-11T21:45:26+00:00Added an answer on June 11, 2026 at 9:45 pm

    Note that Selectors doesn’t use the term “operator”. The > and + symbols are more accurately known as combinators, while the comma is merely a symbol used to group selectors into a list, and doesn’t belong in the same category as the > and + combinators.

    As of Selectors level 4, combinators define a relationship between two elements, so they are indeed binary. And you can indeed use > or + multiple times in succession to refer to grandparents or other adjacent siblings. For example, div > p > span represents the following HTML fragment:

    <div>
      <p>
        <span></span>
      </p>
    </div>
    

    And div + p + span represents the following fragment:

    <div></div>
    <p></p>
    <span></span>
    

    You can also mix and match combinators to represent even more complex structures. For example, div + p > span represents a <span> whose parent is a <p> which in turn directly follows a <div>, as given by the following fragment:

    <div></div>
    <p>
      <span></span>
    </p>
    

    Switching the combinators around, div > p + span represents a <span> that directly follows a <p> which in turn is a child of a <div>:

    <div>
      <p></p>
      <span></span>
    </div>
    

    Notice how this implies that both the <span> and the <p> are children of the same <div>.

    Keep in mind though that every complex selector targets the rightmost element (known as the subject of the selector). Unfortunately, this coupled with combinators being binary means that not all structures can be represented. See my answer to this question for an extremely in-depth explanation of both of these concepts and why such a limitation arises as a result.


    You can also use , multiple times to group as many selectors together as you like, but again this is separate from the notion of combinators. The difference is that combinators link elements together to form a complex selector representing a singular cohesive structure, whereas the comma groups multiple complex selectors into a single CSS rule for the sake of convenience.

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

Sidebar

Related Questions

For a webpage I used a div id that with css inserts a logo
How can one get a left floating element with a top position. For instance:
I'm using cloneNode(true) to make copies of DOM elements (for instance a div containing
I know that jQuery.extend can be used to add by own custom methods to
I have a div id=result that I use to display results of users actions.
How can I add an item before the siblings? For instance, <div class=item>1</div> <div
How can I use jQuery to get a particular instance of a class(headerGrid) within
I've created a very simple helper class that I can use in my ASP.Net
How do I move a div after its next div. For instance I have
For instance: I have a swf, lets say A, that loads another swf, B.

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.