(1) 태그 선택자
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>01-01_태그 선택자</title>
<style type="text/css">
* { color: blue; }
p { color: red; }
h3, h4, h5, span {
color: orange;
}
h3 {
color: gray;
}
</style>
</head>
<body>
<h2>선택자</h2>
<br/>
<p>페이지의 태그를 선택할 때 사용합니다</p>
<br/>
<h3>여러개의 태그에 하나의 선언 적용</h3>
<h4>여러개의 태그에 하나의 선언 적용</h4>
<h5>여러개의 태그에 하나의 선언 적용</h5>
<span>여러개의 태그에 하나의 선언 적용</span>
</body>
id_class 선택자
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>01-02_id_class 선택자</title>
<style type="text/css">
#select_1 { color: red; }
#select_2 { color: blue; }
.title { color: brown; }
h4.title { color: orange; }
.type {
color: gray;
font-weight: bold;
}
</style>
</head>
<body>
<h2>id 선택자</h2>
<p id="select_1"># 으로 시작해서 웹 페이지에서 CSS 로 꾸미고자 하는 id 선택</p>
<p id="select_2"># 으로 시작해서 웹 페이지에서 CSS 로 꾸미고자 하는 id 선택</p>
<br/>
<h2>class 선택자</h2>
<h3 class="title">난초</h3>
<h4 class="title">- 난초의 특성</h4>
<p>난초는 외떡잎 식물중에서 가장 진화한 식물</p>
<br/>
<h4>- 난초의 종류</h4>
<p><span class="type">동양란</span>과 <span class="type">서양란</span>으로 구별하며...</p>
</body>
</html>
(3) 하위 선택자
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>01-03_하위 선택자</title>
<style type="text/css">
#header h2 { color: blue; }
#section h2 { color: red; }
#content p { color: olive; }
</style>
</head>
<body>
<h1>하위 선택자</h1>
<br/>
<div id="header">
<h2>header</h2>
<div id="nav">
<h3>navigation</h3>
</div>
</div>
<br/>
<div id="section">
<h2>section</h2>
<p>section area</p>
</div>
<br/>
<h1>heading</h1>
<div id="content">
<p>문단 A</p>
<p>문단 B</p>
<div>
<p>문단 C</p>
</div>
</div>
<p>문단 D</p>
</body>
</html>
(4) 자식 선택자
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>01-04_자식 선택자</title>
<style type="text/css">
#section > h3 { color: red; }
#section > ul > li { color: blue; }
#content > p { color: gold; }
</style>
</head>
<body>
<h1>자식 선택자</h1>
<br/>
<div id="section">
<h3>음료</h3>
<ul>
<li>커피</li>
<li>주스</li>
<li>콜라</li>
</ul>
</div>
<br/>
<h1>heading</h1>
<div id="content">
<p>문단 A</p>
<p>문단 B</p>
<div>
<p>문단 C</p>
</div>
</div>
<p>문단 D</p>
</body>
</html>
(5) 기본 속성 선택자
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>01-05_기본 속성 선택자</title>
<style type="text/css">
input[type] { color: gray; }
input[type=password] { background-color: yellow; }
</style>
</head>
<body>
<h1>기본 속성 선택자</h1>
<br/>
<form action="#">
<p>text : <input type="text" id="data" name="data"/></p>
<br/>
<p>password : <input type="password" id="pwd" name="pwd"/></p>
</form>
</body>
</html>
(6) 인접 선택자
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>01-06_인접 선택자</title>
<style type="text/css">
h2 + h3 { color: red; }
h2 ~ h3 { background-color: orange; }
</style>
</head>
<body>
<h1>인접 선택자</h1>
<h3>제목 - 3</h3>
<h2>제목 - 2</h2>
<h3>제목 - 3</h3>
<h3>제목 - 3</h3>
<h3>제목 - 3</h3>
<div id="content">
<h3>content - h3</h3>
</div>
<h3>제목 - 3</h3>
</body>
</html>
(7) 반응 선택자
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>01-07_반응 선택자</title>
<style type="text/css">
a:link { color: orange; }
a:visited { color: green; }
a:hover {
color: red;
background-color: yellow;
}
#test-1 a:active { color: blue; }
</style>
</head>
<body>
<h1>반응 선택자</h1>
<h2 id="test-1"><a href="https://www.naver.com" target="_blank">NAVER</a></h2>
<h2 id="test-2"><a href="https://www.daum.net" target="_blank">DAUM</a></h2>
</body>
</html>
(8)상태 선택자
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>01-08_상태 선택자</title>
<style type="text/css">
input:checked + span { color: red; }
input:enabled + span { background-color: yellow; }
input:disabled + span { text-decoration: line-through; }
#test-a:focus { background-color: pink; }
#test-b:focus { background-color: skyblue; }
</style>
</head>
<body>
<h1>상태 선택자</h1>
<br/>
<div>
<p><input type="checkbox" value="bicycle" checked/><span>bicycle</span></p>
<p><input type="checkbox" value="car"/><span>car</span></p>
<p><input type="checkbox" value="motocycle" disabled/><span>motorcycle</span></p>
</div>
<br/>
<p>focus 테스트 a : <input type="text" id="test-a"/></p>
<p>focus 테스트 b : <input type="text" id="test-b"/></p>
</body>
</html>
(9) 구조 선택자
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>01-09_구조 선택자</title>
<style type="text/css">
ul > li {
font-size: 30px;
font-weight: bold;
}
ul > li:nth-child(2n) { color: lightgreen; }
ul > li:nth-child(2n+1) { color: brown; }
ul > li:first-child { color: blue; }
ul > li:last-child { color: red; }
p { font-size: 24px; }
p:first-of-type { color: orange; }
p:last-of-type { color: green; }
p:nth-of-type(2) { background-color: pink; }
</style>
</head>
<body>
<h1>일반 구조 선택자</h1>
<ul>
<li>one</li>
<li>two</li>
<li>three</li>
<li>four</li>
<li>five</li>
<li>six</li>
<li>seven</li>
</ul>
<br/>
<h1>형제 구조 선택자</h1>
<p>h1 - p1</p>
<p>h1 - p2</p>
<p>h1 - p3</p>
<p>h1 - p4</p>
<br/>
<div>
<h2>제목 - h2</h2>
<p>h2 - p1</p>
<p>h2 - p2</p>
<p>h2 - p3</p>
<p>h2 - p4</p>
</div>
</body>
</html>
(10) CSS-definition
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>01-10_CSS-definition</title>
<link rel="stylesheet" type="text/css" href="external-style.css"/>
</head>
<body>
<h1>외부 스타일 시트</h1>
<div id="external">
<p>외부 스타일 시트</p>
</div>
</body>
</html>
STYLE.css