μμ± μ νμ
νκ·Έμ μμ±μ μ§μ νλ μ νμ
[name=βemailβ] { }
[data=β1β] { }
CSS
볡μ¬
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>μμ± μ νμ</title>
<style>
section {
margin: 20px 0;
}
/*
[μμ±] { }
[μμ±='A'] { } : μμ±='A' μμλ₯Ό μ ν
[μμ±^='A'] { } : μμ±='A'λ‘ μμνλ μμ μ ν
[μμ±$='A'] { } : μμ±='A'λ‘ λλλ μμ μ ν
[μμ±*='A'] { } : μμ±='A'λ₯Ό ν¬ν¨νλ μμ μ ν
*/
/* sectionνκ·Έ, μμ± : id, μμ±κ° : '2' λλλ κ° */
section[id$='2'] {
background-color: yellow;
padding: 10px;
}
/* div νκ·Έ, μμ±λͺ
class */
div[class] {
padding: 5px;
margin: 5px;
border: 1px solid #ccc;
}
/* μμ±κ°μ΄ 'l'λ‘ μμνλ κ²½μ° */
div[class^='l'] { background-color: skyblue; }
/* μμ±κ°μ 'i'κ° ν¬ν¨λλ κ²½μ° */
div[class*='i'] { background-color: pink; }
/* μμ±κ°μ΄ '4'λ‘ λλλ κ²½μ° */
div[class$='4'] { background-color: royalblue; }
/*
μμ±κ°μ΄ 'e'κ° ν¬ν¨λκ³
μμ±κ°μ΄ '2'λ‘ λλλ κ²½μ°
*/
div[class*='e'][class$='2'] {
background-color: springgreen;
}
</style>
</head>
<body>
<h1>μμ± μ νμ</h1>
<hr>
<section id="part1">
<div class="lst1">μμ±μ νμ 1</div>
<div class="lis2">μμ±μ νμ 2</div>
<div class="le2">μμ±μ νμ 3</div>
<div class="l4">μμ±μ νμ 4</div>
</section>
<hr>
<section id="part2">
<div class="lst1">μμ±μ νμ 1</div>
<div class="lis2">μμ±μ νμ 2</div>
<div class="le2">μμ±μ νμ 3</div>
<div class="l4">μμ±μ νμ 4</div>
</section>
</body>
</html>
HTML
볡μ¬