Visualizing selectors is helpful. In this video, practice using compound selectors in a sample HTML document in CodePen.
- [Instructor] It's possible to combine selectors … in all kinds of interesting ways. … We'll cover many of these ways in the course, … but the first way I'd like to discuss … is what's called a compound selector. … So if you take a look here at this code pen, … you'll notice over here in our HTML we have both a paragraph … and a unordered list that have a class of myclass. … They both have red text inside of them … in the display down here on the bottom. … What if I only wanted to have the paragraph appear red, … while the ul appeared blue? … So with a CSS class that I have here right now … that's not going to be possible … because anything with a class of myclass will be red. … However, if I go in ahead and put that HTML element … in front of the myclass selector, … in other words let's just say p.myclass, … then only the paragraph will wind up being red in this case. … And that is because this selector is saying that … for all paragraphs that have that class of myclass … do the following things. …
- 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 Beginner
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.