For example:
div > p.some_class {
/* Some declarations */
}
What exactly does the > sign mean?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
>is the child combinator, sometimes mistakenly called the direct descendant combinator.1That means the selector
div > p.some_classonly matches paragraphs of.some_classthat are nested directly inside adiv, and not any paragraphs that are nested further within. This implies that every element matchingdiv > p.some_classnecessarily also matchesdiv p.some_class, with the descendant combinator (space), so the two are understandably often confused.An illustration comparing the child combinator with the descendant combinator:
Which elements are matched by which selectors?
Matched by both
div > p.some_classanddiv p.some_classThis
p.some_classis located directly inside thediv, hence a parent-child relationship is established between both elements. Since "child" is a type of "descendant", any child element is by definition also a descendant. Therefore, both rules are applied.Matched by only
div p.some_classThis
p.some_classis contained by ablockquotewithin thediv, rather than thedivitself. Although thisp.some_classis a descendant of thediv, it’s not a child; it’s a grandchild. Therefore, only the rule with the descendant combinator in its selector is applied.1 Many people go further to call it "direct child" or "immediate child", but that’s completely unnecessary (and incredibly annoying to me), because a child element is immediate by definition anyway, so they mean the exact same thing. There’s no such thing as an "indirect child".