--- title: 선택자 목록 slug: Web/CSS/Selector_list tags: - CSS - Reference - Selectors - 선택자 translation_of: Web/CSS/Selector_list --- <div>{{CSSRef}}</div> <p><a href="/ko/docs/Web/CSS">CSS</a> <strong>선택자 목록</strong>(<code>,</code>)은 일치하는 모든 요소를 선택합니다.</p> <pre class="brush: css no-line-numbers notranslate">/* 모든 span과 div 요소 선택 */ span, div { border: red 2px solid; }</pre> <p>다수의 선택자를 쉼표 구분 목록에 넣어 스타일 시트 크기를 줄일 수 있습니다.</p> <h2 id="구문">구문</h2> <pre class="syntaxbox notranslate">element, element, element { <em>style properties</em> }</pre> <h2 id="예제">예제</h2> <h3 id="한_줄_묶기">한 줄 묶기</h3> <p>쉼표로 구분한 목록을 한 줄에 배치할 수 있습니다.</p> <pre class="brush: css notranslate">h1, h2, h3, h4, h5, h6 { font-family: helvetica; } </pre> <h3 id="여러_줄_묶기">여러 줄 묶기</h3> <p>쉼표로 구분한 목록을 여러 줄에 배치할 수도 있습니다.</p> <pre class="brush: css notranslate">#main, .content, article { font-size: 1.1em; } </pre> <h3 id="선택자_목록_무효화">선택자 목록 무효화</h3> <p>선택자 목록의 단점은, 다음의 두 경우가 서로 같지 않다는 점입니다.</p> <pre class="brush: css notranslate">h1 { font-family: sans-serif } h2:maybe-unsupported { font-family: sans-serif } h3 { font-family: sans-serif }</pre> <pre class="brush: css notranslate">h1, h2:maybe-unsupported, h3 { font-family: sans-serif }</pre> <p>왜냐하면 목록 내의 하나의 선택자라도 브라우저가 지원하지 않으면 전체 목록을 무효화하기 때문입니다.</p> <p>대응 방법은 {{CSSxRef(":is", ":is()")}} 선택자를 사용하는 것을 통해, 유효하지 않은 선택자를 무시하는 것입니다. 그러나 <code>:is()</code>가 명시도를 계산하는 방법으로 인해, 모든 선택자가 동일한 명시도를 갖게 되는 부작용이 있습니다.</p> <pre class="brush: css notranslate">h1 { font-family: sans-serif } h2:maybe-unsupported { font-family: sans-serif } h3 { font-family: sans-serif }</pre> <pre class="brush: css notranslate">:is(h1, h2:maybe-unsupported, h3) { font-family: sans-serif }</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", "#grouping", "Selector Lists")}}</td> <td>{{Spec2("CSS4 Selectors")}}</td> <td>Renamed to "selector list"</td> </tr> <tr> <td>{{SpecName('CSS1', '#grouping', 'grouping')}}</td> <td>{{Spec2('CSS1')}}</td> <td>Initial definition</td> </tr> </tbody> </table> <h2 id="브라우저_호환성">브라우저 호환성</h2> <p>{{Compat("css.selectors.list")}}</p> <h2 id="같이_보기">같이 보기</h2> <ul> <li>선택자 목록 무효화라는 과거의 실수를 가지지 않는 {{CSSxRef(":is", ":is()")}} {{Experimental_Inline}}, {{CSSxRef(":where", ":where()")}} {{Experimental_Inline}} 의사 클래스.</li> </ul>