sanguk.dev
작성완료
스타일 상속/적용 우선순위

스타일 상속/적용 우선순위

모든 CSS 프로퍼티가 상속되는 것은 아니며, 상속되지 않은 속성에 inherit을 적용할 수 있다. 스타일 적용 우선순위는 선언 위치와 명시도, 선언 순서에 따라 달라진다.

CSS & SASS & SCSS

모든 프로퍼티가 상속되는 것은 아니다.

plain
width/height = no
margin = no
padding = no
border = no
box-sizing = no
display = no
visibility = yes
opacity = yes
background = no
font = yes
color = yes
line-height = yes
text-align = yes
vertical-align = no
text-decoration = no
white-space = yes
position = no
top/right/bottom/left = no
z-index = no
overflow = no
float = no

상속되지 않은 속성에 inherit을 적용하면 상속시킬 수 있다.

우선순위

  • 중요도! 어디에 선언이 되었는가? (ex. head태그내부 / inline Style / CSS 외부파일 등)
  • 명시도! 어떤 선택자를 얼마나 구체적으로 조합했는가? (ex. ID선택자 / Class선택자)
  • 선언 순서