<div style="...">내용</div>
<style> p {color: gray;} </style>
p태그에만 적용됨.<link rel = "stylesheet" href = "css/style.css">
@import url('css/style.css');
h1 { color: blue; }
h2 { color: blue; }
h3 { color: blue; }
h4 { color: blue; }
h5 { color: blue; }
h6 { color: blue; }
h1, h2, h3, h4, h5, h6 { color: blue; }
*{color: blue;} // 전체선택자 *(별표, asterisk)로 문서내 모든 요소 선택. 한 번의 선언으로 문서 내에 모든 요소에 스타일 규칙이 적용.
h1 { color: yellow; font-size: 2em; background-color: gray; }
h1, h2, h3, h4, h5, h6 { color: yellow; font-size: 2em; background-color: gray; }
<p>
이면서 class속성에 bar가 있어야 적용됨. /* 요소와 class의 조합 */
p.bar { ... }
/* 다중 class */
.foo.bar { ... }
/* id와 class의 조합 */
#foo.bar { ... }
속성 선택자
p[class] {color: red;}
p[class][id] {text-decoration:underline;}
<p class= "hey">hey</p>
<p class= "hey" id= "hi">hi</p>
p[class="hey"] { color: silver; }
p[id="hi"] { text-decoration: underline; }
<p class= "hey">hey</p> /* silver컬러 적용 */
<p class= "yey">yey</p> /* 해당사항 없음 */
<p id= "hi">hi</p> /* 언더라인 생성 */
<p class="color hot">red</p>
<p class="cool color">blue</p>
<p class="colorful nature">rainbow</p>
p[class~="color"] { font-style: italic; } /* 1, 2번째 요소 */
p[class^="color"] { font-style: italic; } /* 1, 3번째 요소 */
p[class$="color"] { font-style: italic; } /* 2번째 요소 */
p[class*="color"] { font-style: italic; } /* 1, 2, 3번째 요소 */