Can I target all tags with a single selector?

后端 未结 10 1676
予麋鹿
予麋鹿 2020-12-04 08:44

I\'d like to target all h tags on a page. I know you can do it this way...

h1,
h2,
h3,
h4,
h5,
h6 {
  font: 32px/42px trajan-pro-1,trajan-pro-2;
}

10条回答
  •  不思量自难忘°
    2020-12-04 09:24

    You can also use PostCSS and the custom selectors plugin

    @custom-selector :--headings h1, h2, h3, h4, h5, h6;
    
    article :--headings {
      margin-top: 0;
    }
    

    Output:

    article h1,
    article h2,
    article h3,
    article h4,
    article h5,
    article h6 {
      margin-top: 0;
    }
    

提交回复
热议问题