Answer: Parent-child selector is a selector representing the direct descendent of a parent element. Parent-child selectors are created by listing two or more tilde (~) separated selectors.
BODY ~ P {background: red; color: white} The P element will be declared the specified style only if it directly descends from the BODY element: <BODY> <P>Red and white paragraph </P> </BODY>
BODY ~ P ~ EM {background: red; color: white} The EM element will be declared the specified style only if it directly descends from the P element which in its turn directly descends from the BODY element:
Parent-child selector is a selector representing the direct descendent of a parent element. Parent-child selectors are created by listing two or more tilde (~) separated selectors.
BODY ~ P {background: red; color: white} The P element will be declared the specified style only if it directly descends from the BODY element: <BODY> <P>Red and white paragraph </P> </BODY>
BODY ~ P ~ EM {background: red; color: white} The EM element will be declared the specified style only if it directly descends from the P element which in its turn directly descends from the BODY element:
< <P> <EM>Red and white EM </EM> </P> </BODY Source: CoolInterview.com
If you have the better answer, then send it to us. We will display your answer after the approval.
Rules to Post Answers in CoolInterview.com:-
There should not be any Spelling Mistakes.
There should not be any Gramatical Errors.
Answers must not contain any bad words.
Answers should not be the repeat of same answer, already approved.