官术网_书友最值得收藏!

Descendant selectors

Renaming elements with classes, as you learned in the previous section, is an extremely powerful feature in CSS. However, that's not the only way to target a specific type of element. Descendant selectors will allow you to target elements on a page based on their ancestor elements. This is often necessary because you only want to apply a margin or a new font based on the context of the element. You can use a descendant selector to get that context without putting a class on every element every time you want to target it. I'm going to first explain what parent, sibling, and child elements are as well as what ancestor and descendant elements are. We'll need to be clear about these if we want to use descendant selectors. We'll follow this up by using a practical example of the descendant selector and finishing up by calculating the descendant selector's weight.

主站蜘蛛池模板: 上虞市| 三原县| 蒙山县| 盐源县| 海南省| 淮滨县| 历史| 临桂县| 广平县| 峨眉山市| 红桥区| 内黄县| 阳原县| 彭泽县| 澄城县| 英超| 土默特左旗| 尼木县| 星座| 杭锦后旗| 济南市| 手游| 凌源市| 灵川县| 江津市| 阳西县| 喜德县| 德庆县| 红原县| 德阳市| 咸阳市| 铜川市| 睢宁县| 页游| 镇赉县| 蛟河市| 江达县| 舟山市| 楚雄市| 佛冈县| 松阳县|