YouTip LogoYouTip

Css Combinators

# CSS Combinators * * * ## CSS Combinators | ![Image 2: Note](#) | Combinators explain the relationship between two selectors. | | --- | CSS combinators describe the relationship between selectors. CSS3 includes four types of combinators: * Descendant selector (separated by a space) * Child selector (separated by a greater-than sign `>`) * Adjacent sibling selector (separated by a plus sign `+`) * General sibling selector (separated by a tilde `~`) * * * ## Descendant Selector The descendant selector is used to select descendant elements of a specific element. The following example selects all `

` elements that are inserted within `

` elements: ## Example ```css div p { background-color: yellow; } [Try it yourself Β»](#) * * * ## Child Selector Compared to the descendant selector, the child selector can only select elements that are direct/first-level children of a specific element. The following example selects all direct child `

` elements of `

` elements: ## Example ```css div > p { background-color: yellow; } [Try it yourself Β»](#) * * * ## Adjacent Sibling Selector The adjacent sibling selector selects an element that is immediately preceded by another element, and both share the same parent element. If you need to select an element that is immediately after another element, and both have the same parent, you can use the adjacent sibling selector. The following example selects the first `

` element that is immediately after a `

` element: ## Example ```css div + p { background-color: yellow; } [Try it yourself Β»](#) * * * ## General Sibling Selector The general sibling selector selects all sibling elements that follow a specified element. The following example selects all `

` elements that are siblings following a `

` element: ## Example ```css div ~ p { background-color: yellow; } [Try it yourself Β»](#)
← Prop Style AligncontentProp Time Datetime β†’

YouTip © 2024-2026 | Home | Learn Technology, Build Dreams!

All content is for educational and learning purposes only.