HTML <span>
요소는 구문 콘텐츠를 위한 통용 인라인 컨테이너로, 본질적으로는 아무것도 나타내지 않습니다. 스타일을 적용하기 위해서, 또는 lang
등 어떤 특성의 값을 서로 공유하는 요소를 묶을 때 사용할 수 있습니다. 적절한 의미를 가진 다른 요소가 없을 때에만 사용해야 합니다. <span>
은 <div>
와 매우 유사하지만, <div>
는 블록 레벨 요소인 반면 <span>
은 인라인 요소입니다.
The source for this interactive example is stored in a GitHub repository. If you'd like to contribute to the interactive examples project, please clone https://github.com/mdn/interactive-examples and send us a pull request.
콘텐츠 카테고리 | 플로우 콘텐츠, 구문 콘텐츠. |
---|---|
가능한 콘텐츠 | 구문 콘텐츠. |
태그 생략 | None, both the starting and ending tag are mandatory. |
가능한 부모 요소 | 구문 콘텐츠 또는 플로우 콘텐츠를 허용하는 모든 요소. |
가능한 ARIA 역할 | 모두 |
DOM 인터페이스 | HTMLSpanElement |
특성
이 요소는 전역 특성만 포함합니다.
예제
예제 1
HTML
<p><span>Some text</span></p>
결과
예제 2
HTML
<li><span>
<a href="portfolio.html" target="_blank">See my portfolio</a>
</span></li>
CSS
li span {
background: gold;
}
Result
명세
명세 | 상태 | 코멘트 |
---|---|---|
HTML Living Standard The definition of '<span>' in that specification. |
Living Standard | |
HTML5 The definition of '<span>' in that specification. |
Recommendation | The DOM interface is now HTMLSpanElement . |
HTML 4.01 Specification The definition of '<span>' in that specification. |
Recommendation |
브라우저 호환성
BCD tables only load in the browser
The compatibility table in 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.
같이 보기
- HTML
<div>
요소