CSS advanced selectors help you target elements on your webpage more precisely. Whether you’re styling lists, creating hover effects, or working with sibling elements, these selectors make life easier! Here’s a breakdown with examples to make things clear. 🚀


1. Child Selector (>) 👶

ul > li {
  color: red; /* Only styles the direct <li> elements inside the <ul> */
}

Example:

✅ Styled:

<ul>
  <li>Direct Child</li>
</ul>

❌ Not Styled:

<ul>
  <li>
    <ul>
      <li>Nested Child</li>
    </ul>
  </li>
</ul>


2. Adjacent Sibling Selector (+) 🤝

h2 + p {
  font-size: 16px; /* Styles the <p> right after <h2> */
}


3. General Sibling Selector (~) 🎯

h1 ~ p {
  color: gray; /* Styles all <p> elements that come after an <h1> */
}