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.

Understanding only selectors, :only-child, :only-of-type

Understanding only selectors, :only-child, :only-of-type - CSS Tutorial

From the course: CSS: Selectors

Start my 1-month free trial

Understanding only selectors, :only-child, :only-of-type

- [Instructor] The next topic is the only selectors, including only child and only of type. Let's talk about the easy one first. That is the only child selector. Just like in real life, an only child is one without siblings of that particular type. So let's go ahead and take a look at an example of this. We have here in line number eight, we have a strong tag here that's all by itself. It is an only child. Also, if you take a look here in line six, this strong tag at the end of the sentence is an only child also. It is a child of the M tag which is surrounding that. So if we go ahead and write a strong colon only child, we wind up getting both of those things selected. That's the definition of an only child. There it is. Only of type is a little bit different. So that indicates that there may be several siblings, but there's only one of this particular type. So an example of that is here in the aside, the aside actually has two children, it has an H2 and it has a paragraph. But the H2…

Contents