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.
Descendant selectors
- [Instructor] Consider this piece of HTML. It's very, very similar to what you just saw in the HTML family tree discussion. Now, what I'd like to do, is I'd like to style the link in the paragraph without styling the link that's in the list. Sure, the easiest thing to do here would be to drop in a class, and then style the class, but before long, classes would take over our document. Also, on occasion, you don't have access to the HTML to change it. That can be true with parts of content management systems like WordPress or Drupal. If that's the case, how can I style the link in the paragraph without affecting the link in the list? So, typically the way we'd style a link is simply say, a, and then we'd say something like color: red, but that of course is going to style both of our links, and turn them both red. So, how do I get just the one in the paragraph? Well, a descendant selector is a very simple way of doing this. Remember that a descendant is simply indicates that it is…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.