Child Selector vs. Descendant Selector in Table Structures
When selecting elements in HTML documents, developers often use child selectors (>) to target direct children and descendant selectors to target any nested element. However, there are scenarios where the child selector seems to fail unexpectedly.
Consider the following example:
table tr td { background-color: red; } table > tr > td { background-color: blue; }
The first rule successfully selects all
elements. Puzzled by this behavior, developers might assume that since | is a child of |
In this modified structure,
since it is not an immediate child of |
Disclaimer: All resources provided are partly from the Internet. If there is any infringement of your copyright or other rights and interests, please explain the detailed reasons and provide proof of copyright or rights and interests and then send it to the email: [email protected] We will handle it for you as soon as possible.
Copyright© 2022 湘ICP备2022001581号-3