What is the difference between:
li ul {color:red;}
and
li > ul {color:yellow;}
I try both and get the same result.
What is the difference between:
li ul {color:red;}
and
li > ul {color:yellow;}
I try both and get the same result.
The first selector covers all ul inside li.
The second cover only the direct ul descendant inside li.
For more selectors tips, see this links
The first selector is known as the Descendant combinator whereas the second one is the Child combinators
Descendant combinator
li ul {color:red;}
At times, authors may want selectors to describe an element that is the descendant of another element in the document tree (e.g., "an EM element that is contained within an H1 element"). Descendant combinators express such a relationship. A descendant combinator is whitespace that separates two sequences of simple selectors. A selector of the form "A B" represents an element B that is an arbitrary descendant of some ancestor element A.
Child combinators
li > ul {color:yellow;}
A child combinator describes a childhood relationship between two elements. A child combinator is made of the "greater-than sign" (U+003E, >) character and separates two sequences of simple selectors.