CSS 전체 선택자(*
)는 모든 형태의 모든 요소를 선택합니다.
/* Selects all elements */
* {
color: green;
}
CSS 3부터는 별표를 네임스페이스
와 함께 사용할 수 있습니다.
ns|*
- 네임스페이스 ns 안의 모든 요소 선택*|*
- 모든 요소 선택|*
- 네임스페이스 없는 모든 요소 선택
구문
* { style properties }
단순 선택자에서 별표는 선택사항입니다. 즉 *.warning
과 .warning
은 같습니다.
예제
CSS
* [lang^=en] {
color: green;
}
*.warning {
color: red;
}
*#maincontent {
border: 1px solid blue;
}
.floating {
float: left
}
/* automatically clear the next sibling after a floating element */
.floating + * {
clear: left;
}
HTML
<p class="warning">
<span lang="en-us">A green span</span> in a red paragraph.
</p>
<p id="maincontent" lang="en-gb">
<span class="warning">A red span</span> in a green paragraph.
</p>
결과
명세
명세 | 상태 | 설명 |
---|---|---|
Selectors Level 4 The definition of 'universal selector' in that specification. |
Working Draft | 변화 없음 |
Selectors Level 3 The definition of 'universal selector' in that specification. |
Recommendation | 네임스페이스에 관한 행동이 정의되고 선택자 생략이 가상 요소 내에서 허용된다는 힌트가 추가됨 |
CSS Level 2 (Revision 1) The definition of 'universal selector' in that specification. |
Recommendation | 초기 정의 |
브라우저 호환성
BCD tables only load in the browser
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.