![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
I'm trying to learn CSS2, find some aspects of it quite confusing.. here, http://www.w3.org/TR/REC-CSS2/selector.html#q1 I see this: E F : Matches any F element that is a descendant of an E element. Descendant selectors E > F : Matches any F element that is a child of an element E. Child selectors please, what is difference between a descendant and a child element.. thank you. |
#3
| |||
| |||
|
|
maya wrote: I'm trying to learn CSS2, find some aspects of it quite confusing.. here, http://www.w3.org/TR/REC-CSS2/selector.html#q1 I see this: E F : Matches any F element that is a descendant of an E element. Descendant selectors E > F : Matches any F element that is a child of an element E. Child selectors please, what is difference between a descendant and a child element.. thank you. Your child is your child. Your descendant can be your child, your grandchild, your great-grandchild, etc. |
#4
| |||
| |||
|
|
Harlan Messinger wrote: maya wrote: I'm trying to learn CSS2, find some aspects of it quite confusing.. here, http://www.w3.org/TR/REC-CSS2/selector.html#q1 I see this: E F : Matches any F element that is a descendant of an E element. Descendant selectors E > F : Matches any F element that is a child of an element E. Child selectors please, what is difference between a descendant and a child element.. thank you. Your child is your child. Your descendant can be your child, your grandchild, your great-grandchild, etc. ok, thank you very much.. I had thought maybe they were different relationships.. |
#5
| |||||
| |||||
|
|
A child is a descendant, yes. But although a descendant can be a child, a descendant can also be a grandchild, etc. |
|
To put it back in CSS terms - (using your case above) assume the style: div.E div.F { background-color: red; } |
|
both class "F" divs would have a red background. |
|
BUT if you defined the style as: div.E > div.F { background-color: red; } ONLY the second one would have a red background - since the first one is a descendant, but NOT a CHILD of "E". |
|
.F are generally not useful in CSS authoring for the WWW at present or in the near future, since they are not supported by IE 6. Of course, if you are |
![]() |
| Thread Tools | |
| Display Modes | |
| |