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

  • Mastering CSS
  • Rich Finelli
  • 153字
  • 2021-07-08 09:45:53

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.

主站蜘蛛池模板: 前郭尔| 敦化市| 蒙城县| 谷城县| 宜黄县| 黄山市| 太和县| 宜昌市| 淳化县| 逊克县| 北宁市| 乌恰县| 京山县| 唐山市| 邢台市| 阳西县| 公主岭市| 西昌市| 霍山县| 美姑县| 曲水县| 苏尼特左旗| 鄂尔多斯市| 锡林郭勒盟| 信阳市| 怀仁县| 中山市| 广东省| 南涧| 徐闻县| 连州市| 湘潭县| 宜宾县| 那曲县| 阳西县| 米易县| 新津县| 高青县| 盐边县| 正阳县| 漳浦县|