inline
<h1 style="color: red; font-style: italic">Hello world</h1>
HTML 내부에 stylesheet 작성
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>page title</title>
<style>
h1 {
color: red;
font-style: italic;
}
/* 모든 h1 태그에 빨간색, 기울임꼴을 적용 */
</style>
</head>
<body>
<h1>Hello world</h1>
<div>Contents here
<span>Here too!</span>
</div>
</body>
</html>
index.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>page title</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<h1>Hello world</h1>
<div>Contents here
<span>Here too!</span>
</div>
</body>
</html>
만일 다음 문서에서 hello world에는 빨간색, code states에는 파란색을 적용하고 싶을 경우는?
index.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>page title</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<h1>Hello world</h1>
<h1>code states</h1>
</body>
</html>
style.css
h1 {color: red}
SOLUTION 1: 각각의 ELEMENT에 고유한 ID를 부여
index.html
<h1 id="hello">Hello world</h1>
<h1 id="codestates">code states</h1>
style.css
#hello {color:red;}
#codestates {color: blue;}