Usually in the code practice, often use the descendant selector, Sub-selectors will also be used, here to do a summary:
1, descendants selector and child selector differ:
① does not have the same wording:
Descendant selectors are identified as: spaces
Such as: ul li{width:150px;} "between ul and Li is separated by a space"
The child selector is identified as:>
Such as: ul>li{width:150px;} "> separated between UL and li"
The ② function is not the same:
Descendant selectors (descendant selector), also known as containing selectors, can select elements of an Element's descendants , as in the previous example, the descendant selector is all the LI elements in all elements surrounded by a selection of ul, including son elements, grandson elements, Great-grandchild elements, and so On.
In contrast to descendant selectors, child selectors can only select elements that are elements of the son element of an element, and the sub-selector selects only the LI element in the son element that surrounds the ul, not including the grandchild element, the Great-grandchild element, and so On.
③ compatibility is not the same:
The descendant selector is compatible with mainstream Browsers.
Sub-selectors in IE6 are not supported selectors, will be out bug!
2, descendant selector and childexamples of using selectors in Combination:
Take a look at the selector below:
Table.company td > P
The selector above selects all the P elements as child elements of the TD element, and the TD element itself is inherited from a TABLE element that class= "company".
CSS descendant selectors and Sub-selectors