การใช้คำสั่ง Selector :is

คำสั่ง selector :is เพื่อลดทอนการเขียนโค้ดที่ยาวๆ

ตัวอย่างโค้ด CSS ปกติ

.post h1,
.post h2,
.post h3 {
line-height: 1.2;
}
.post img,
.post video {
width: 100%;
}

ตัวอย่างโค้ด CSS เมื่อใช้ :is

.post :is(h1, h2, h3) {
line-height: 1.2;
}
.post :is(img, video) {
width: 100%;
}

ตัวอย่างการแสดงผล

codepen

ที่มา

smashingmagazine