CSS是该父类的第一种类型,但不是进一步的子类

CSS是该父类的第一种类型,但不是进一步的子类,css,less,Css,Less,我想选择第一个p,但不选择嵌套在blockquote中的p或任何其他元素 换句话说,所有子p中的第一个p,但不是孙子p <div class="article__body"> <p> It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. </p> <bloc

我想选择第一个
p
,但不选择嵌套在blockquote中的
p
或任何其他元素

换句话说,所有子
p
中的第一个
p
,但不是孙子
p

<div class="article__body">
  <p>
    It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged.
</p>
<blockquote>
  <p>
    It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged.
  </p>
</blockquote>
<p>
    It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged.
</p>
</div>

也许你应该试试这个:

.article_body p:nth-of-type(1){
    background-color:green;
}
或者只是创建一个类 HTLM:

CSS:
.yourclass{背景色:绿色;}

我试试看

.article__body p:nth-of-type(1){
            background-color:green;
        }

使用
组合器。在询问之前,你应该认真考虑搜索。“哈里,是的,完全正确。<代码>。TooLySo.BooS> P:第一个孩子{} /代码>?@ BANZAY:<代码>:第一种类型更好,只是在外部<代码> P<代码>不是第一个孩子的情况下。
.article__body p:nth-of-type(1){
            background-color:green;
        }