HTML
<div>HELLO World!</div>
CSS
div {
font-size: 50px
color: blue;
text-decoration: underline;
}
😘 margin : 여백
<style>
div {
color: red;
margin: 20px;
}
</style>
<div style="color: red; margin: 20px;"></div>
HTML
<link rel="stylesheet" href="./css/main.css">
CSS
CSS
div {
color: red;
margin: 20px;
}
HTML
<link rel="stylesheet" href="./css/main.css">
CSS(main)
@import url("./box.css")
div {
color: red;
margin: 20px;
}
`CSS(box)`
.box {
background-color: red;
padding: 20px;
}
* {
color: red;
}
li {
color: red;
}
HTML
<li class="orange">오렌지</li>
CSS
.orange {
color: red;
}
HTML
<li id="orange" class="orange">오렌지</li>
CSS
#orange {
color: red;
}
복합 일치선택자 선택자 ABC복합 자식선택자 선택자 ABC복합 하위(후손)선택자 선택자 ABC복합 인접형제선택자 선택자 ABC복합 일반형제선택자 선택자 ABC<div class="fruits">
<span>딸기</span>
<span>수박</span>
<div>오렌지</div>
<p>망고</p>
<h3>사과</h3>
</div>
ABC:first-child
가상클래스선택자 first child 선택자 ABC 가 형제 요소 중 첫째라면 선택
fruits span:first-child { }
Error fruits div:first-child { }
ABC:last-child
가상클래스선택자 last child 선택자 ABC 가 형제 요소 중 막내라면 선택
fruits h3:last-child { }
ABC:nth-child(n)
가상클래스선택자 NTH CHILD 선택자 ABC 가 형제 요소 중 (n)번째라면 선택
fruits *:nth-child(2) { } /형제요소상관업음
ABC:not(XYZ)
부정 선택자 NOT 선택자 XYZ 가 아닌 ABC 요소 선택
ABC::before
가상요소선택자 BEFORE 선택자 ABC 요소의 내부 앞에 내용(content)을 삽입
HTML
<div class="box">
Content!
</div>
CSS
.box::before {
content: "앞!";
}
앞! Content!
animal 이라는 클래스를 가지고 있는 요소에, CSS를 적용했을 때 그 적용된 내용이 그 해당하는 요소의 자식요소(하위요소)을 포함시킴(상속요소)
HTML
<div class="ecosystem">생태계
<div class="animal">동물
<div class="tiger">호랑이</div>
<div class="lion">사자</div>
<div class="elephant">코끼리</div>
</div>
<div class="plant">식물</div>
</div>
CSS
.animal {
color: red;
}
동물, 호랑이, 사자, 코끼리 만 빨간색
모두 글자/문자 관련 속상들을 의미함(모든건 아님 주의!)

hello world 만 빨간색으로 변함
