目标不是标题

时间:2016-02-09 16:18:17

标签: html css selector

我正在尝试编写一个CSS选择器来定位所有不属于标题的元素(h1h2h3,...)

我用谷歌搜索“所有不是标题css”和“not headings css”。没有任何相关内容,所以我决定在这里问。

我试过这样做:

body :not( h1, h2, h3, h4, h5, h6 ) {
  /* yada yada yada */
}

我注意到这有效:

body :not(h1), body :not(h2), body :not(h3) /* et cetera */ {
  /* yada yada yada */
}

但我宁愿不必输入所有内容,我担心它会使我的代码难以导航。有更简单的方法吗?

1 个答案:

答案 0 :(得分:2)

链接:not选择器

body *:not(h1):not(h2):not(h3) /* et cetera */ {
 color:red
}

body *:not(h1):not(h2):not(h3)
/* et cetera */

{
  color: red
}
<p>Red Text</p>

<h1>Black H1</h1>

<h2>Black H2</h2>