CSS와 HTML의 분리

CSS와 HTML의 분리

 

아시다시피 html의 <head> 안에는 3가지가 들어간다. 첫째, 스타일. 둘째, 스크립트, 셋째, 타이틀.

다시 말해서,

<!doctype html>

 <head>

 <style>

 table{font-size:12px;}

 </style>

 

 <script type=”text/javascript”>

 function a(){alert(“하하”);}

 </script>

 <title>타이틀</title>

 </head>

 <body>

 </body>

</html>

 

이런식으로 쓰기 마련이다.

 

중요한 점은 이러한 html 파일 1개를 파일 3개로 나눌 수 있다.

 

html 파일

<!doctype html>
     <head>
          <link rel=”stylesheet” href=”c.css”>
          <script src=”j.js” type=”text/javascript”></script>
     </head>

     <body>

 

     </body>
</html>

 

c.css 파일

table{font-size:12px;}

 

j.js 파일

function a(){alert(“하하”);}

 

위와 같이 나눠서 쓰면 편리하다.