Cascading Style Sheets
스타일링을 위한 일종의 언어
선택자
Element에 스타일이 적용되는 규칙
특정 html태그를 선택
h1 {
color: green;
}
ID 기반으로 선택
<div id="section">
...
</div>
#section {
background-color: black;
}
여러 개의 Element를 분류하기 위해 사용
<span class="medium">
...
</span>
<p class="medium">
...
</p>
.medium {
font-size: 20px;
}
p.medium {
font-size: 20px;
}
h1.medium {
font-size: 20px;
}
전체 Element를 적용
* {
font-size: 20px;
color: blue;
}
여러가지 선택자를 그룹으로 묶어 하나의 style로 적용
h1, h2, p {
color: black;
text-align: center;
}
button:hover {
font-weight: bold;
}
a:active {
color: red;
}
input:focus {
color: #0000000;
}
option:checked {
background: #00ff00;
}
p:first-child {
background: #ff0000;
}
p:last-child {
background: #0000ff;
}