How can you select all child elements recursively?
div.dropdown, div.dropdown > * { color: red; }
This class only throws a class on the defined className and all immediate children. How can you, in a simple way, pick all childNodes like this:
div.dropdown, div.dropdown > *, div.dropdown > * > *, div.dropdown > * > * > *, div.dropdown > * > * > * > * { color: red; }
The * selector selects all elements. The * selector can also select all elements inside another element (See "More Examples").
The element > element selector selects those elements which are the children of the specific parent. The operand on the left side of > is the parent and the operand on the right is the children element.
When designing and developing web applications, sometimes we need to select all the child elements of an element except the last element. To select all the children of an element except the last child, use :not and :last-child pseudo classes.
This selector is used to select every element which is not the first-child of its parent element. It is represented as an argument in the form of :not(first-child) element.
Use a white space to match all descendants of an element:
div.dropdown * { color: red; }
x y
matches every element y that is inside x, however deeply nested it may be - children, grandchildren and so on.
The asterisk *
matches any element.
Official Specification: CSS 2.1: Chapter 5.5: Descendant Selectors
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With