Notice
Recent Posts
Recent Comments
Link
«   2024/09   »
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
Tags
more
Archives
Today
Total
관리 메뉴

재훈재훈

CSS Selectors 1 본문

Computer Engineering/HTML & CSS

CSS Selectors 1

jaehoonx2 2018. 10. 27. 20:28

CSS Selectors (선택자)



[이미지 출처: w3school.com]



CSS 는 크게 선택자 ( h1 ) 와 선언부 (중괄호 부분) 으로 나누어진다.

선택자는 HTML elements, 즉 태그들을 지칭하고,

각각의 선언부 블록들은 어떻게 꾸며지느냐, 내용에 관한 부분이다.


선택자는 HTML 문서에서 element를 각각의 이름, id, 클래스 등으로 찾는 데 쓰인다.



선택자의 종류

1. 타입 선택자 (type selector) - element의 이름에 기반해서 특정 element를 찾는다.

p {

text-align : center;

color : red;

}


1-1. 여러 개를 동시에 사용할 수 있다. (Grouping Selectors)

h1, h2, p {

text-align : center;

color: red;

}




2. ID 선택자 (ID Selector) - id를 이용해서 특정 element를 찾는다.

#para {

text-align : center;

color: red;

}




3. 클래스 선택자 (Class selector) -클래스를 이용해서 특정 element를 찾는다.

p.center {

text-align : center;

color: red;

}





'Computer Engineering > HTML & CSS' 카테고리의 다른 글

How to use frameset tag (example code)  (0) 2018.10.29
HTML Entities  (0) 2018.10.29
CSS Selectors 2  (0) 2018.10.27