CSS CSS Basics Basic Selectors Descendant Selectors

Elizabeth Leon-Guerrero
Elizabeth Leon-Guerrero
Front End Web Development Techdegree Student 1,680 Points

What are the benefits of using Descendant Selectors?

Hi! At the end of the video, Guil mentions that using descendant selectors make the css rules less reusable and that we're better off using a class for the element.

So is there any particular benefit to using a descendant selector? and what are some situations in which a Descendant Selector would be more handy?

1 Answer

Steven Parker
Steven Parker
203,989 Points

They are always "handy" because you wouldn't need to modify the HTML. But since they depend on one thing being inside another, a more direct selection method (like giving things the same class) makes the rule more "reusable".

The situation would determine how much of a drawback this might be, as re-usability might not even be a factor in some cases.

Elizabeth Leon-Guerrero
Elizabeth Leon-Guerrero
Front End Web Development Techdegree Student 1,680 Points

Ahh, I see - so, for some projects it's not necessary for a rule to be reusable, in which case it's a bit quicker and just as effective to target the html with a descendent selector instead of assigning a class or id... okay, I get it now! thanks!