Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Understanding more complex examples of descendant selectors

Tags:

html

css

I somewhat understand descendant selectors, but the more complex examples are giving me trouble. For example:

#content .alternative p

Should this rule apply to p elements that are descendants of elements E, where E are :

  • descendants of element #content and
  • are also members of class .alternative

Or should rule apply to p elements that are:

  • descendants of element #content
  • and are also members of class .alternative?

How about the following rule?

#content .alternative .alternative1 p
like image 931
carewithl Avatar asked Dec 21 '09 19:12

carewithl


1 Answers

About the first question: applies to p elements that are: descendants of element #content and also descendants of elements with class .alternative

The second one is the same, just with an extra level of depth.

Check this link for more info on selectors

like image 122
Januz Avatar answered Sep 28 '22 14:09

Januz