CSS를 웹문서에 적용하는데는 다섯가지 방법이 있습니다.
- style속성을 개별 엘리먼트에 적용하기
1
<
p
style
=
"color: red;"
>인라인으로 스타일 적용하기</
p
>
- <head>안에 style 엘리먼트로 적용하기
12345
<
style
type
=
"text/css"
>
p {
color: red;
}
</
style
>
- <head>안에 link 엘리먼트를 이용하여 외부 스타일시트 불러오기
1
<
link
rel
=
"stylesheet"
type
=
"text/css"
href
=
"/css/style.css"
/>
- <head>안에서 @import로 외부 스타일시트 불러오기
123
<
style
type
=
""
text/css>
@import url ("/css/style.css");
</
style
>
- xml-stylesheet처리 명령으로 외부 스타일시트 불러오기
1
<?
xml-stylesheet
type
=
"text/css"
href
=
"/css/style.css"
?>
위 다섯가지 적용방법중 html문서안에 직접 스타일을 기술하는 1번과 2번은 추천되지 않습니다. 마크업과 표현(css)이 철저하게 분리되는 3, 4, 5번을 추천하고 있습니다.