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

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.

主站蜘蛛池模板: 武强县| 神农架林区| 甘洛县| 宁蒗| 沿河| 衡山县| 肥城市| 昌图县| 巴里| 镇康县| 自治县| 民县| 潼关县| 无极县| 进贤县| 三门峡市| 河间市| 左云县| 黔东| 武威市| 瓦房店市| 蛟河市| 武安市| 运城市| 盐津县| 泾阳县| 中牟县| 新巴尔虎右旗| 嘉兴市| 玛纳斯县| 华坪县| 昌江| 布拖县| 花莲市| 泰兴市| 贞丰县| 顺义区| 清丰县| 霍林郭勒市| 万盛区| 临沧市|