Answers for "adjacent sibling selector"

CSS
4

adjacent sibling selector

/*The adjacent sibling combinator (+) separates two 
selectors and matches the second element only if 
it immediately follows the first element, and
both are children of the same parent element.*/

li:first-of-type + li {
  color: red;
}

<ul>
  <li>One</li> // The sibling 
  <li>Two</li> // This adjacent sibling will be red
  <li>Three</li>
</ul>
Posted by: Guest on March-11-2020
4

css selector for sibling element

/* Paragraphs that come immediately after any image */
img + p {
  font-weight: bold;
}
Posted by: Guest on April-29-2020

Browse Popular Code Answers by Language