提问者:小点点

在CSS中,“div:first-of-type[label=”hello“]”与“div[label=”hello“]:first-of-type”不同吗?


在CSS中,此选择器是:

div:first-of-type[label=“hello”]

任何不同于:

div[label=“hello”]:第一种类型


共1个答案

匿名用户

与伪元素不同,伪类可以出现在选择器的中间:

在一个选择器中包含的所有简单选择器序列中都允许伪类。 在简单选择器序列中的任何地方都允许伪类,在前导类型选择器或通用选择器(可能省略)之后。 参考

所以两者都是一样的

null

div[label="hello"]:first-of-type {
  height:50px;
}


div:first-of-type[label="hello"] {
  border:5px solid;
}
<div label="hello" class="box"></div>