Using descendant selectors occasionally selects more than you intended. In this video, learn how parent-child CSS selectors target elements with that relationship.
- [Instructor] Parent-Child Selectors … are very handy if you want to get … the child element of a given parent. … The Descendant Selector selects all of the descendants … that match a given selector, but the Parent-Child Selector … selects only this specific variety. … So in this example, I've given you some HTML here … where we have an article, inside of the article … we do have an aside as well as some paragraphs … and some headings and so forth. … And what I would like to do is select … only the paragraphs in the article, … not the paragraphs in the aside. … So I could write, start by writing … some kind of selector like this, article p, … color, red … now that's going to select all of the paragraphs … in the document, why is that? … Well, look at the relationship that we have here, … clearly this paragraph on line three … is part of that article, but also … the one here on line six, this is also … descended from article. … The parent of this paragraph is the aside, … the parent of the aside is the article …
- Targeting classes and IDs
- Working with group selectors
- Targeting element attributes
- Targeting links with pseudo-class selectors
- Targeting child elements and empty elements
- Targeting parent, child, and sibling elements
- Best practices for CSS
- The impact of CSS selectors on performance
Skill Level Intermediate
The power of selectors1m 8s
1. Review of Basic CSS
2. Combinator Selectors
3. Attribute Selectors
Simple attribute selectors2m 47s
4. Pseudo-Classes, Pseudo-Elements, and the Universal Selector
5. Choosing Selectors
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.