From the course: CSS: Selectors

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Adjacent and general sibling selectors

Adjacent and general sibling selectors - CSS Tutorial

From the course: CSS: Selectors

Start my 1-month free trial

Adjacent and general sibling selectors

- [Female Narrator] Siblings. Those annoying creatures you had to share parents with. Well, they are all over the place in HTML and fortunately, we have two ways of talking about siblings. First of all we have adjacent siblings, these are siblings that are directly next to each other, not separated by anything at all. So to show you an example of this, lets take a look at the children of the article in this example. In this case we have an h1 here in line two, we have a p in line three, we have an aside in line four and another p down here on line eight, in that specific order. And so that order is going to matter if we're talking about the adjacent siblings. So lets take a look at how the adjacent sibling selector will work in this particular situation. So let's say that I want to select this very first paragraph on this page and only that one. So I'm going to try h1 plus p, color green. So this will select only the paragraph on line three because that is the one that is immediately…

Contents