--- title: ':root' slug: 'Web/CSS/:root' tags: - CSS - Layout - Pseudo-class - Reference - Selector - Web translation_of: 'Web/CSS/:root' --- <div>{{CSSRef}}</div> <p><a href="/ko/docs/Web/CSS">CSS</a> <strong><code>:root</code></strong> <a href="/ko/docs/Web/CSS/Pseudo-classes">의사 클래스</a>는 문서 트리의 루트 요소를 선택합니다 HTML의 루트 요소는 {{htmlelement("html")}} 요소이므로, <code>:root</code>의 <a href="/ko/docs/Web/CSS/Specificity">명시도</a>가 더 낮다는 점을 제외하면 <code>html</code> 선택자와 똑같습니다.</p> <pre class="brush: css no-line-numbers notranslate">/* 문서의 루트 요소 선택 HTML에서는 <html> */ :root { background: yellow; }</pre> <h2 id="구문">구문</h2> {{csssyntax}} <h2 id="예제">예제</h2> <h3 id="전역_CSS_변수_선언하기">전역 CSS 변수 선언하기</h3> <p><code>:root</code>는 전역 <a href="/ko/docs/Web/CSS/Using_CSS_custom_properties">CSS 변수</a> 선언에 유용하게 사용할 수 있습니다.</p> <pre class="brush: css notranslate">:root { --main-color: hotpink; --pane-padding: 5px 42px; } </pre> <h2 id="명세">명세</h2> <table class="standard-table"> <thead> <tr> <th scope="col">Specification</th> <th scope="col">Status</th> <th scope="col">Comment</th> </tr> </thead> <tbody> <tr> <td>{{SpecName('CSS4 Selectors', '#root-pseudo', ':root')}}</td> <td>{{Spec2('CSS4 Selectors')}}</td> <td>No change.</td> </tr> <tr> <td>{{SpecName('CSS3 Selectors', '#root-pseudo', ':root')}}</td> <td>{{Spec2('CSS3 Selectors')}}</td> <td>Initial definition.</td> </tr> </tbody> </table> <h2 id="브라우저_호환성">브라우저 호환성</h2> <p>{{Compat("css.selectors.root")}}</p> <h2 id="같이_보기">같이 보기</h2> <ul> <li>{{htmlelement("html")}}</li> <li>{{domxref("Document.rootElement")}}</li> <li>{{domxref("Node.getRootNode()")}}</li> <li>{{domxref("Node.rootNode")}}</li> <li>{{domxref("Element.shadowRoot")}}</li> <li>{{domxref("ShadowRoot")}}</li> </ul>