Cascading Style Sheets의 약어
HTML의 각 요소의 style을 정의하여 화면 등에 어떻게 렌더링할 것인지 브라우저에게 설명하기 위한 용어
HTML와 CSS는 별개의 언어임
HTML는 CSS 포함 가능하나, HTML 없이 CSS 단독 존재 X
rule set : selector에 의해 선택된 HTML 요소를 어떻게 렌더링할 것인지 브라우저에게 지시하는 구문
style sheet : rule set의 집합
p {
color : ...;
font : ...;
}
p {
color: orange;
font-size: 16px;
}
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="css/style.css">
</head>
<body>
<h1>Hello World</h1>
<p>This is web page</p>
</body>
</html>
h1 {color: red;}
p {background: blue;}
<!DOCTYPE html>
<html>
<head>
<style>
h1 {color: red;}
p {background: blue;}
</style>
</head>
<body>
<h1>Hello World</h1>
<p>This is a web page</p>
</body>
</html>
<!DOCTYPE html>
<html>
<body>
<h1 style="color: red">Hello World</h1>
<p style="background: blue">This is a web page</p>
</body>
</html>
기본적인 HTML 요소의 CSS를 초기화하는데 사용
브라우저 별로 제각각인 디폴트 스타일을 하나의 스타일로 통일시켜 주는 역할
자주 사용되는 Reset CSS : Eric Meyer's reset, normalize.css
Eric Meyer's reset css
/* http://meyerweb.com/eric/tools/css/reset/
v2.0 | 20110126
License: none (public domain)
*/
html, body, div, span, applet, object, iframe,
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
a, abbr, acronym, address, big, cite, code,
del, dfn, em, img, ins, kbd, q, s, samp,
small, strike, strong, sub, sup, tt, var,
b, u, i, center,
dl, dt, dd, ol, ul, li,
fieldset, form, label, legend,
table, caption, tbody, tfoot, thead, tr, th, td,
article, aside, canvas, details, embed,
figure, figcaption, footer, header, hgroup,
menu, nav, output, ruby, section, summary,
time, mark, audio, video {
margin: 0;
padding: 0;
border: 0;
font-size: 100%;
font: inherit;
vertical-align: baseline;
}
/* HTML5 display-role reset for older browsers */
article, aside, details, figcaption, figure,
footer, header, hgroup, menu, nav, section {
display: block;
}
body {
line-height: 1;
}
ol, ul {
list-style: none;
}
blockquote, q {
quotes: none;
}
blockquote:before, blockquote:after,
q:before, q:after {
content: '';
content: none;
}
table {
border-collapse: collapse;
border-spacing: 0;
}