CSS Descendant Selector
Notes:
CSS – Descendant Selector (White space):
Descendants of a node are any node falling under the selected node tree.
(i.e. Direct Children, Children’s Children, and so on or any node that can be reachable from the selected node to the leaf nodes are considered as descendants of node)
It selects any html element targeted by the selector written after the space character, which is/are descendant(s) of the any html element targeted by the selector written before the space character.
Syntax of CSS rule-set / rule:
selector
{
declaration list;
}
To implement descendant selector, in place of selector; we write selectors one beside another separated by the white space character
Syntax of Descendant Selector:
selector1 selector2
{
declaration list;
}
It selects any html element targeted by selector2, which is descendant(s) of any html element targeted by selector1
Ex:
div p
{
border:2px solid red;
}
It selects any p element, which is descendant of any div element
Interview Questions:
1. Which symbol indicates descendant selector in CSS?
a. tilde
b. space
c. plus
d. greater than
Answer: b