Logo

TODAY I LEARNED

98a3314c36e4e45959eaba7a0c9074fb

1 post by carlos-pineda

:is() pseudo-class - CSS

When we apply the same style to multiple selectors on CSS we use to do something like this:

.section-header h1,
.section-header span,
.section-header .heading {
  line-height: 1.2;
}
.navigation li,
.navigation p {
  padding: 5px 10px;
}

With :is() we can write our CSS in a shorter way.

.section-header :is(h1, span, .heading) {
  line-height: 1.2;
}
.navigation :is(li, p) {
  padding: 5px 10px;
}

Learned by carlos-pineda on Apr 19, 2021

973983 adforcodereview v3 0211021 c02 021121