Programming/css

css 문법 - id / class

구차니 2016. 1. 11. 14:02



The id Selector

The id selector uses the id attribute of an HTML element to select a specific element.

The id of an element should be unique within a page, so the id selector is used to select one unique element!

To select an element with a specific id, write a hash (#) character, followed by the id of the element.

The style rule below will be applied to the HTML element with id="para1":


The class Selector

The class selector selects elements with a specific class attribute.

To select elements with a specific class, write a period (.) character, followed by the name of the class.

In the example below, all HTML elements with class="center" will be red and center-aligned:


[링크 : http://www.w3schools.com/css/css_syntax.asp]


id는 유일한 거라고 하지만.. 크롬이나 ie에서 실험적으로 해봐도

경고나 에러를 띄우진 않는데.. 머가 맞는걸려나..

[링크 : http://okky.kr/article/89313]

[링크 : http://www.homejjang.com/07/class_id.php