소스


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <style>
        *{
            padding: 0px;
            margin: 0px;
        }
        div{
            width: 100px;
            height: 100px;
        }
        /*띄어쓰기는 자식을 포함한 모든 자식들에게 적용 / 콤마는(,) 자신까지 */
        body div{
            border-bottom-color: black;
            border-width: 1px;
            border-style: solid;
        }
        body>div>div{
            width: 50px;
            height: 50px;
            background-color: antiquewhite;
        }
        body>div>div>div{
            width: 30px;
            height: 30px;
            background-color: aquamarine;
        }
        /*차이점 확인하기 첫번째 자식한테만 해당*/
        body>div>div:first-child{
            background-color: blueviolet;
        }
        body>div:last-child{
            background-color: fuchsia;
        }
        
    </style>
</head>
<body>
    <div>1</div>
    <div>2</div>
    <div>3</div>
    <div>
        <div>4</div>
    </div>
    <div>  
        <div>
            <div>5</div>
        </div>
    </div>
    
</body>
</html>
cs


결과



* 우선순위 알기

우선순위가 높은 것 부터 나열

 인라인(<div style=""> : 사용하지않는게 좋다) > id(#) > 선택자(:) > class(.) > 태그지시자 ( 우선순위가 같다면 오버라이드 )


+ Recent posts