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

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.

主站蜘蛛池模板: 洛阳市| 和林格尔县| 潮州市| 阳朔县| 黄陵县| 永登县| 门头沟区| 皮山县| 南投市| 太保市| 子长县| 射阳县| 公安县| 嫩江县| 白银市| 墨江| 兴山县| 广平县| 凭祥市| 盖州市| 八宿县| 伊春市| 禹城市| 高唐县| 绥阳县| 宝兴县| 清水县| 沾化县| 乐安县| 栾川县| 唐河县| 庄河市| 赣州市| 凤阳县| 聂拉木县| 惠州市| 灵石县| 黄浦区| 贡觉县| 霍林郭勒市| 青海省|