CSS ID 선택자는 요소의 id 속성 값을 비교하여 완전히 동일한 id를 가진 요소를 선택합니다.

/* id="demo" 요소 선택 */
#demo {
  border: red 2px solid;
}

구문

#id_value { style properties }

위의 구문은 속성 선택자를 사용한 다음 구문과 동일합니다.

[id=id_value] { style properties }

예제

CSS

#identified {
  background-color: skyblue;
}

HTML

<div id="identified">특별한 ID를 가진 요소에요!</div>
<div>이건 그냥 div에요.</div>

결과

명세

Specification Status Comment
Selectors Level 4
The definition of 'ID selectors' in that specification.
Working Draft  
Selectors Level 3
The definition of 'ID selectors' in that specification.
Recommendation  
CSS Level 2 (Revision 1)
The definition of 'ID selectors' in that specification.
Recommendation  
CSS Level 1
The definition of 'ID selectors' in that specification.
Recommendation Initial definition

브라우저 호환성

Update compatibility data on GitHub
DesktopMobile
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidFirefox for AndroidOpera for AndroidSafari on iOSSamsung Internet
ID selector (#idName)Chrome Full support 1Edge Full support 12Firefox Full support 1IE Full support 3Opera Full support YesSafari Full support 1WebView Android Full support ≤37Chrome Android Full support 18Firefox Android Full support 4Opera Android Full support YesSafari iOS Full support 1Samsung Internet Android Full support 1.0

Legend

Full support  
Full support

문서 태그 및 공헌자

태그: 
이 페이지의 공헌자: alattalatta
최종 변경자: alattalatta,