CSS κ΅¬μ²΄μ± λ¨μ (μ°μ μμ)
λ€μν μ
λ ν°λ€μ΄ κ°μ μμλ₯Ό κ°λ¦¬ν€λ©΄ μμκ° μ ν΄μ ΈμΌ νλ€. μ΄κ²μ κ΅¬μ²΄μ± λ¨μλΌκ³ λΆλ₯΄λλ°, κ° μμλ€μ μ ν΄μ§ μ μκ° μλ€. κ·Έ μ μκ° λμ μμλλ‘ μ°μ μμλ‘ μ ν΄μ§λ€.
λͺ
μ λ°©λ² |
μ μ |
TAG |
1 |
Class |
10 |
Id |
100 |
HTML νκ·Έμ style μμ± μ¬μ© (Inline Style) |
1000 |
- Inline Style
- μ
λ ν°μ Idκ° λ§μ κ²½μ°
- μ
λ ν°μ class, μμ±(attribute), κ°μ ν΄λμ€(pseudo-class)κ° λ§μ κ²½μ°
- μΌλ°μ μΈ μμ λλ κ°μ μμκ° λ§μ κ²½μ°
/** μμ **/
div.bbs_content { /* tag 1 + class 1 = 11μ */}
body > div#container > div#header {/* tag 3 + id 2 = 203μ */}
body, p, span, input, textarea {/*tag 5 = 5μ */}
μμ
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style type="text/css">
div { color: purple;} /* 1μ */
div > h1#title { color: blue; } /* 102μ */
div#container div.box { color: orange; } /* 112μ */
div#container .item { color: green; } /* 111μ */
#container #active { color: red; } /* 200μ */
div#container > ul > li { color: black; } /* 103μ */
</style>
</head>
<body>
<div id="container">
<h1 id="title">ꡬ체μ±λ¨μ</h1> <!-- blue -->
ꡬ체μ±λ¨μλ₯Ό μμλ΄
μλ€. <!-- purple -->
<div class="box"> <!-- orange -->
CSSμ ννκΈ°λ²μ λ°λΌμ μ μκ° λΆμ¬λ©λλ€.
</div>
<ul>
<li class="item" id="active">id: 100μ </li> <!-- red -->
<li class="item">class: 10μ </li> <!-- green -->
<li>tag: 1μ </li> <!-- black -->
</ul>
</div>
</body>
</html>