Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags

css
html

What is CSS immediate child?

Nouman Abbasi

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.

The CSS child combinator (>) can be used to select all elements that are the immediate children of a specified element.

A combinator combines and explains the relationship between two or more selectors.

Syntax

selector1 > selector2 { style properties }

It matches only those elements matched by the second selector (selector2) that are the direct children of elements matched by the first selector (selector1).

Code

In this example, add a background-color property to all the immediate child (p) elements of the parent (div) element.

  • HTML
  • CSS

Notice that the CSS property does not apply to the third p element as it is not an immediate child.

RELATED TAGS

css
html

CONTRIBUTOR

Nouman Abbasi
Copyright ©2022 Educative, Inc. All rights reserved

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.

Keep Exploring