Combinators and Selector Lists
CSS employs a number of tokens in order to represent lists or to provide relational context between two selectors.
Selector Lists
Selector lists use the comma (,) to join multiple selectors in a list. When presented with a selector list, any
selector in the list that matches an element will return that element.
Descendant Combinator
Descendant combinators combine two selectors with whitespace ( ) in order to signify that the second
element is matched if it has an ancestor that matches the first element.
Additional Reading
https://developer.mozilla.org/en-US/docs/Web/CSS/Descendant_combinator
Warning
Selectors like the descendant and subsequent sibling combinators (a b and a ~ b) often cause entire
subtrees of the main document tree to be crawled when evaluating a single element. If used poorly, this can impact
performance in a non-linear ways. It should be noted that Soup Sieve employs caching to reduce performance concerns in
various cases, but there will always be the potential produce non-linear cases simply due to how the selectors work.
Child combinator
Child combinators combine two selectors with > in order to signify that the second element is matched if it has a
parent that matches the first element.
Additional Reading
https://developer.mozilla.org/en-US/docs/Web/CSS/Child_combinator
General Sibling Combinator
General sibling combinators combine two selectors with ~ in order to signify that the second element is matched
if it has a sibling that precedes it that matches the first element.
Additional Reading
https://developer.mozilla.org/en-US/docs/Web/CSS/General_sibling_combinator
Warning
Selectors like the descendant and subsequent sibling combinators (a b and a ~ b) often cause entire
subtrees of the main document tree to be crawled when evaluating a single element. If used poorly, this can impact
performance in a non-linear ways. It should be noted that Soup Sieve employs caching to reduce performance concerns in
various cases, but there will always be the potential produce non-linear cases simply due to how the selectors work.
Adjacent Sibling Combinator
Adjacent sibling combinators combine two selectors with + in order to signify that the second element is matched
if it has an adjacent sibling that precedes it that matches the first element.
Additional Reading
https://developer.mozilla.org/en-US/docs/Web/CSS/Adjacent_sibling_combinator