CSS element1~element2 Selector

❮ Previous Selectors Next ❯

Example

div ~ p {
  background: red;
}

Meaning

The sibling selector selects all elements that are preceding siblings of a specified element.

The above example selector matches all p elements that appear immediately after div elements.

Version: CSS3




Standard Syntax

element1 ~ element2 {
  css declarations;
}



Browser Support

The numbers in the table specify the first browser version that fully supports the property.




Status







❮ Previous Selectors Next ❯