white-space
Baseline
Widely available
*
This feature is well established and works across many devices and browser versions. Itâs been available across browsers since 2015ë 7ì.
* Some parts of this feature may have varying levels of support.
CSS white-space ìì±ì ììê° ê³µë°± 문ì를 ì²ë¦¬íë ë²ì ì§ì í©ëë¤.
ìëí´ ë³´ê¸°
white-space: normal;
white-space: pre;
white-space: pre-wrap;
white-space: pre-line;
white-space: wrap;
white-space: collapse;
white-space: preserve nowrap;
<section class="default-example" id="default-example">
<div id="example-element">
<p>
But ere she from the church-door stepped She smiled and told us why: 'It
was a wicked woman's curse,' Quoth she, 'and what care I?' She smiled, and
smiled, and passed it off Ere from the door she steptâ
</p>
</div>
</section>
#example-element {
width: 16rem;
}
#example-element p {
border: 1px solid #c5c5c5;
padding: 0.75rem;
text-align: left;
}
ì°¸ê³ :
ë¨ì´ ììì ì¤ì´ ë°ë기를 ìíë ê²½ì° overflow-wrap, word-break, hyphens를 ì¬ì©íì¸ì.
구문
/* Keyword values */
white-space: normal;
white-space: nowrap;
white-space: pre;
white-space: pre-wrap;
white-space: pre-line;
white-space: break-spaces;
/* Global values */
white-space: inherit;
white-space: initial;
white-space: unset;
white-space ìì±ì ë¤ì 목ë¡ì í¤ìë ê° ì¤ íë를 ì¬ì©í´ ì¤ì í©ëë¤.
ê°
normal-
ì°ì 공백ì íëë¡ í©ì¹¨. ê°í 문ìë ë¤ë¥¸ 공백 문ìì ëì¼íê² ì²ë¦¬í©ëë¤. í ì¤ì´ ë무 길ì´ì ëì¹ ê²½ì° ìëì¼ë¡ ì¤ì ë°ê¿ëë¤.
nowrap-
ì°ì 공백ì íëë¡ í©ì¹¨. ì¤ ë°ê¿ì
<br>ììììë§ ì¼ì´ë©ëë¤. pre-
ì°ì 공백 ì ì§. ì¤ ë°ê¿ì ê°í 문ìì
<br>ììììë§ ì¼ì´ë©ëë¤. pre-wrap-
ì°ì 공백 ì ì§. ì¤ ë°ê¿ì ê°í 문ìì
<br>ìììì ì¼ì´ëë©°, í ì¤ì´ ë무 길ì´ì ëì¹ ê²½ì° ìëì¼ë¡ ì¤ì ë°ê¿ëë¤. pre-line-
ì°ì 공백ì íëë¡ í©ì¹¨. ì¤ë°ê¿ì ê°í 문ìì
<br>ìììì ì¼ì´ëë©°, í ì¤ì´ ë무 길ì´ì ëì¹ ê²½ì° ìëì¼ë¡ ì¤ì ë°ê¿ëë¤. break-spaces-
ë¤ì ì°¨ì´ì ì ì ì¸íë©´
pre-wrapê³¼ ëì¼í©ëë¤.- ì°ì ê³µë°±ì´ ì¤ì ëì ìì¹íëë¼ë ê³µê°ì ì°¨ì§í©ëë¤.
- ì°ì 공백ì ì¤ê°ê³¼ ëììë ìëì¼ë¡ ì¤ì ë°ê¿ ì ììµëë¤.
- ì ì§í ì°ì 공백ì
pre-wrapê³¼ ë¬ë¦¬ ìì ë°ê¹¥ì¼ë¡ ëì¹ì§ ìì¼ë©°, ê³µê°ë ì°¨ì§íë¯ë¡ ë°ì¤ì ë³¸ì§ í¬ê¸°(min-content,max-content)ì ìí¥ì ì¤ëë¤.
ë¤ìì ì¬ë¬ê°ì§ white-space ê°ì ëìì ì 리í íì
ëë¤.
| ê°í 문ì | ì¤íì´ì¤, í | ìë ì¤ ë°ê¿ | ì¤ ëì 공백 | |
|---|---|---|---|---|
normal |
ë³í© | ë³í© | ì | ì ê±° |
nowrap |
ë³í© | ë³í© | ìëì¤ | ì ê±° |
pre |
ì ì§ | ì ì§ | ìëì¤ | ì ì§ |
pre-wrap |
ì ì§ | ì ì§ | ì | ë침 |
pre-line |
ì ì§ | ë³í© | ì | ì ê±° |
break-spaces |
ì ì§ | ì ì§ | ì | ì¤ ë°ê¿ |
íì 구문
white-space =
normal |
pre |
pre-wrap |
pre-line |
<'white-space-collapse'> || <'text-wrap-mode'> || <'white-space-trim'>
<white-space-collapse> =
collapse |
discard |
preserve |
preserve-breaks |
preserve-spaces |
break-spaces
<text-wrap-mode> =
wrap |
nowrap
<white-space-trim> =
none |
discard-before || discard-after || discard-inner
ìì
>기본 ìì
code {
white-space: pre;
}
<pre> ìì ë´ë¶ì ì¤ ë°ê¿
pre {
word-wrap: break-word; /* IE 5.5-7 */
white-space: pre-wrap; /* current browsers */
}
ì¤ì ë¡ ë³´ê¸°
HTML
<p>
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor
incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis
nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore
eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt
in culpa qui officia deserunt mollit anim id est laborum.
</p>
CSS + ê²°ê³¼
ëª ì¸
| Specification |
|---|
| CSS Text Module Level 4 > # white-space-property > |
| Scalable Vector Graphics (SVG) 2 > # TextWhiteSpace > |
| ì´ê¸°ê° | normal |
|---|---|
| ì ì©ëì | all elements |
| ìì | yes |
| ê³ì° ê° | as specified |
| Animation type | discrete |
ë¸ë¼ì°ì í¸íì±
ê°ì´ 보기
- ë¨ì´ ìììì ìë ì¤ ë°ê¿ ë°©ìì ì§ì íë ìì±:
overflow-wrap,word-break,hyphens