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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T14:48:28+00:00 2026-06-04T14:48:28+00:00

What is the purpose of ~ and > in CSS? For example what does

  • 0

What is the purpose of ~ and > in CSS? For example what does the following expression mean?

:checked ~ label ~ .content > *
  • 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-04T14:48:31+00:00Added an answer on June 4, 2026 at 2:48 pm

    Your selector means:

    Select any element
    that is a child of an element with the class content
    which follows a label
    which in turn follows a :checked input element.

    > is the child combinator. It selects elements that are children of a certain parent element. Unlike the space (the descendant combinator), it only selects immediately-nested elements. See this answer for an illustration on how it works.

    ~ is the general sibling combinator. It selects elements that follow after other elements within the same parent (i.e. are siblings). Unlike + (the adjacent sibling combinator), it doesn’t require an element to immediately follow another in the same parent. Compare the illustration below to this other answer which covers the + combinator.

    Be careful, as the ~ combinator does not just select any sibling element. It only selects an element that comes after its sibling, so :checked ~ label will not match a label that occurs before the checked input element.

    An illustration:

    <section>
        <input type="radio" name="example1" value="1" checked>
        <label>1</label>
        <input type="radio" name="example1" value="2">
        <label>2</label>
        <input type="radio" name="example1" value="3">
        <label>3</label>
    
        <div class="content">
            <h3>Subheading 1</h3>     <!-- [1] Selected -->
            <p>Some text              <!-- [1] Selected -->
               <em>with emphasis</em> <!-- [2] Not selected -->
            </p>
            <p>Some text</p>          <!-- [1] Selected -->
        </div>
    </section>
    
    <section>
        <input type="radio" name="example2" value="1">
        <label>1</label>
        <input type="radio" name="example2" value="2">
        <label>2</label>
        <input type="radio" name="example2" value="3">
        <label>3</label>
    
        <div class="content">
            <h3>Subheading 1</h3>     <!-- [3] Not selected -->
            <p>Some text              <!-- [3] Not selected -->
               <em>with emphasis</em> <!-- [2] Not selected -->
            </p>
            <p>Some text</p>          <!-- [3] Not selected -->
        </div>
    </section>
    

    What’s selected and what’s not:

    1. Selected
      This h3 or p element is located directly inside a .content parent element. That .content element follows at least one label, and this label occurs after at least one input element that is :checked.

      Note that any of the radio buttons here can be checked, and the elements will match, because as mention above ~ doesn’t require a label to follow it immediately. Also, given the structure, either one of the ~ selectors can be swapped out for a +:

      :checked + label ~ .content > *
      :checked ~ label + .content > *
      

      But this selector:

      :checked + label + .content > *
      

      Will only match if the third radio button is checked, because it’s the only one that’s immediately followed by a label and the .content element.

    2. Not selected
      This em element is nested within one of the p elements which is itself contained within .content. Based on the illustration here, it won’t be selected as it’s not a child of .content.

    3. Not selected
      Unlike in [1], none of the label elements in this section follow any :checked input element. Therefore, nothing is selected here, because it doesn’t satisfy :checked ~ label.

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

Sidebar

Related Questions

I have seen following CSS rule at two website /* First example */ background:
Does anyone have a working example of a Wordpress menu outputted manually? The one
Example CSS File: .testClass { color: black; background: red; } Now in an HTML
I'm trying to change the CSS of an HTML element dynamically...for that purpose i
1) I'm confused about the purpose of setting header expiry dates for caching css
Purpose of this web service is to server html/javascript/css/binary data inside simple XML document
I have the following CSS/HTML setup http://jsfiddle.net/UDAUY/ How do I align the drop down
I have the following setup: app/assets/stylesheets/application.css.scss /* *= require_self *= require fancybox */ /*
Trying to run a very simple flot.js example, I have the following code to
Using jQuery I am trying to set focus for (CSS purposes) to a particular

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.