본문 바로가기
css

CSS3 우선순위

by wanee 2015. 1. 28.

우선 순위는
1. Inline style(inside an HTML element) - ​태그 안쪽에 써주는게 가장 우선 순위가 높음
2. Internal style sheet(in the head section) - <head>~</head>에 넣어주는게 두번째
3. External style sheet - ​외부스타일 시트에 적용된것이 3번째
4. Browser default - ​브라우저 기본
태그 곁에 써준것이 적용 우선순위가 가장 높기 때문에, 아무리 외부 스타일 시트에서 적용해줘도 먹히지 않는다 <p style="color:sienna;margin-left:20px;">dfsdfsdfdsfsdfsdf.</p>

 

 

<!DOCTYPE html>
<html>
<head>
<link rel:"stylesheet" type="text/css" href="style.css">
<link>
<style>
/* internal style sheet */
h3 {
color: red;
text-align: right;
font-size: 30pt;
}
</style>
</head>
<body>
<h3>sdfjskdjfklsdf</h3>
</body>
</html>

 

 

이런 경우를 Multiple Style Sheets 라고 부릅니다.
적용 우선 순위는, 외부에서 불러온 스타일(external style sheet) 시트보다는, internal style sheet가 우선이다.
color: red;
text-align: right;
font-size: 30pt;
가 적용이 된다. 색깔은 외부스타일 시트(external style sheet)로부터 상속을 받았고, 나머지는 내부 스타일 시트(internal style sheet)가 적용이 된다.

 

 

 

 

 

 

댓글