지원이 중단된 브라우저를 사용하고 있습니다.
브라우저 업그레이드를 통해 최적화된 화면을 볼 수 있습니다.

Home :is , :where
Post
Cancel

:is , :where

Cross Browsing

:is
:where

view

css

  • :is와 :where은 유사한 구문을 사용
  • :is와 :where의 차이점은 특이성
    • :is는 특이성이 있으며, 재정의 할 때 id 나 class 등이 필요
    • :where는 특이성이 없으며, 재정의 할 때 기본 속성만으로도 가능
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
/* 변경 전 */
section.is a,
footer.is a {
  // color: red;
}

/* 변경 후 */
:is(section.is, footer.is) a {
  color: red;
}

/* 변경 전 */
section.where a,
footer.where a {
  // color: green;
}

/* 변경 후 */
:where(section.where, footer.where) a {
  color: green;
}

참고

This post is licensed under CC BY 4.0 by the author.