HTML·CSS

[CSS] 우선순위

최성2 2022. 2. 13. 01:28

id=100, class=10, tag=1

 

: class가 10개여도 id보다 우선순위가 낮다

 

 

물론, 자신을 직접 선택하는 선택자가 가장 우선된다

 

/* 우선순위: 110 */
#one .two {
	color: red;
}
/* 우선순위: 10 */
.two {
	color: blue;
}
/* 우선순위: 1 */
h2 {
	color: green;
}

 

!important > id > class > tag

 

!important : 어떤 경우에나 이것이 우선 적용 되도록 하고 싶을 때 사용

h1 {
    color: blue !important;
}

 

!important는 최대한 자제하자

: 가중치를 무시하기 때문이다

'HTML·CSS' 카테고리의 다른 글

[CSS] flex  (0) 2022.02.13
[CSS] overflow  (0) 2022.02.11
[CSS] margin & padding  (0) 2022.02.11
[CSS] position  (0) 2022.02.08
[CSS] float  (0) 2022.02.08