선택자 문법
대상
selector {property : val}
선택자의 종류
1) - 요소선택자, 타입선택자, 태그선택자 라고 함
1 2 3 | h3 { font-siez:100%} a {text-decoration:none} img {border : 1} | cs |
2) 그룹선택자 (Groupping)
1 2 3 4 5 6 7 8 9 10 | h3 { font-siez:100%} a {text-decoration:none} img {border : 1} h1, h2, h3, h4 {font-weight: bold} a img p {border : 1} h3 span, h4 span { position : absolute} | cs |
3) 전체선택자 (Universal Selector)
1 2 3 | * {margin : 0; padding:0} html body * {text-decoration:none} p.user * {font-size:15em} | cs |
4) 클래스 선택자 (Class Selector )
1 2 3 | p.notice {font-weight:bold} .container {float:left} .positionX {position:absolute} |
5) 멀티 클래스 선택자 (Multi Class Selector)
1 2 | p.note.container { float:left} .section.news1 {width : 500px} |
6) ID 선택자 (ID Selector)
1 2 | ul#nav {list-style:none;margin:0;padding:0} #user_info{text-decoration:none} | cs |
7) 하위 선택자 (Descendant Selector)
1 2 | ul li a {text-decoration:none} h3 span {postion:absolute;} | cs |
8) 자식 선택자 (Child Combinator)
1 2 3 | body>blockqutoe {color:#4c6a77} p>img {border:0.5px solid whtie;} ul#subNav>li {font-variant:small-caps} | cs |
9) 속성 선택자 (Attribute Selector)
1 2 3 4 | div [id] {font-size:10px;color:red} p [class="note"] {font-size:14px;color:tan} abbr [title~="mobile"] {color:red} img [alt|="love"] {color:purple} | cs |
10) 고급 속성 선택자 ( Advanced Attribute Selector)
1 2 3 4 | a [href^="http://"] {background:url('image.gif)} a [href$=".psd"] {color:blue} img [alt*="css"] {text-decoration:overline} | cs |
11) 가상 클래스 선택자 (Link Pseudo Class Selector)
1 2 3 | a:link, a:visited {color:#999} a:hover, a:active {color:#333} p:hover {color:#78757e} | cs |
참고 : 패스트 캠퍼스 프론트엔드 강의
'HTML&CSS' 카테고리의 다른 글
pt 사이즈를 px로 변환하는 방법 (0) | 2018.12.16 |
---|---|
CSS 선택자 연습 참고 사이트 [CSS Selector][CSS 연습] (0) | 2018.12.08 |
HTML 어휘 강조 표현 (0) | 2018.11.22 |
HTML dl, dt, dd (0) | 2018.11.11 |