1) Adjacent selectors (S1 + S2)
The sibling selector is used to select the specified item, which is located directly next to another specified item. Both elements must be on the same level.
div + p { color:red; }
Adjacent Selectors Example
2) Common siblings selectors (S1 ~ S2)
The brotherβs common selector is used to select all the specified sibling elements of another specified element.
div ~ p { color:red; }
An example of a common choice of siblings
Selector of adjacent brother (S1 + S2) and common brother (S1 ~ S2):
The sibling selector (S1 + S2) selects only the immediate sibling element, but the common sibling selector (S1 ~ S2) selects all sibling elements of the other specified element. In both cases, both elements (S1 and S2) must be at the same level.
Selva May 16 '19 at 12:31 2019-05-16 12:31
source share