From the course: CSS Fundamentals: Unlock the Power of Web Styling

Unlock the full course today

Join today to access over 24,900 courses taught by industry experts.

What are CSS combinators?

What are CSS combinators?

- [Instructor] In CSS lingo, a Combinator is something we can use to explain the relationship between selectors. There are four of them, starting with the descendant selector that you learned about in the previous lesson. It's noted by a space between selectors. Next there's the direct child selector, indicated by the greater than sign. The adjacent sibling selector, indicated by the plus sign. And the general sibling selector, indicated by the tilde. This will make more sense when you see it in action. So let's take a look. So here's the descendant selector, and this says that any span inside of a div matches. It doesn't matter if it's directly after the div or nested a few levels deep, all the spans inside of this div are targeted. Let's turn this into a child selector by adding the greater than sign between our div and our span. In this case, only span elements that are a direct child of the div are selected.…

Contents