스타일 공백 속성
예시
<div> 요소의 텍스트가 줄 바꿈되지 않도록 지정합니다.
document.getElementById("myDIV").style.whiteSpace = "nowrap";
정의 및 사용
whiteSpace 속성은 텍스트의 탭, 줄 바꿈 및 공백을 처리하는 방법을 설정하거나 반환합니다.
브라우저 지원
Property | |||||
---|---|---|---|---|---|
whiteSpace | Yes | Yes | Yes | Yes | Yes |
통사론
공백 속성을 반환합니다.
object.style.whiteSpace
whiteSpace 속성을 설정합니다.
object.style.whiteSpace = "normal|nowrap|pre|initial|inherit"
속성 값
Value | Description |
---|---|
normal | Sequences of whitespace will collapse into a single whitespace. Text will wrap when necessary. This is default |
nowrap | Sequences of whitespace will collapse into a single whitespace. Text will never wrap to the next line. The text continues on the same line until a <br> tag is encountered |
pre | Whitespace is preserved by the browser. Text will only wrap on line breaks. Acts like the <pre> tag in HTML |
pre-line | Sequences of whitespace will collapse into a single whitespace. Text will wrap when necessary, and on line breaks |
pre-wrap | Whitespace is preserved by the browser. Text will wrap when necessary, and on line breaks |
initial | Sets this property to its default value. Read about initial |
inherit | Inherits this property from its parent element. Read about inherit |
기술적 세부 사항
기본값: | 정상 |
---|---|
반환 값: | 요소 내부의 공백이 처리되는 방식을 나타내는 문자열 |
CSS 버전 | CSS1 |
더 많은 예
예시
공백 속성 반환
alert(document.getElementById("myDiv").style.whiteSpace);
관련 페이지
CSS 튜토리얼: CSS 텍스트
CSS 참조: 공백 속성
❮ 스타일 개체