aboutsummaryrefslogtreecommitdiff
path: root/files/de/web/css/white-space/index.html
blob: 5bd5f70eae17818e5139225ebaff1dd65e1e12a5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
---
title: white-space
slug: Web/CSS/white-space
tags:
  - CSS
  - CSS Eigenschaft
  - CSS Text
  - NeedsLiveSample
  - NeedsMobileBrowserCompatibility
  - Referenz
translation_of: Web/CSS/white-space
---
<div>{{CSSRef}}</div>

<p>Die CSS Eigenschaft <strong><code>white-space</code></strong> wird benutzt, um Leerzeichen innerhalb eines Elementes zu handhaben.</p>

<div>{{EmbedInteractiveExample("pages/css/white-space.html")}}</div>

<div class="hidden">Die Quelle für dieses interaktive Beispiel ist in einem GitHub-Repository gespeichert. Wenn Sie zum Projekt der interaktiven Beispiele beitragen möchten, klonen Sie bitte <a href="https://github.com/mdn/interactive-examples">https://github.com/mdn/interactive-examples</a> und senden Sie uns eine Pull-Anfrage.</div>

<div class="note">
<p><strong>Hinweis:</strong> Um Wörter umzubrechen, verwenden Sie stattdessen {{CSSxRef("overflow-wrap")}}, {{CSSxRef("word-break")}}, oder {{CSSxRef("hyphens")}}.</p>
</div>

<h2 id="Syntax" name="Syntax">Syntax</h2>

<pre class="brush: css notranslate">/* Schlüsselwortwerte */
white-space: normal;
white-space: nowrap;
white-space: pre;
white-space: pre-wrap;
white-space: pre-line;
white-space: break-spaces;

/* Globale Werte */
white-space: inherit;
white-space: initial;
white-space: unset;
</pre>

<p>Die Eigenschaft <code>white-space</code> wird als ein einzelnes Schlüsselwort angegeben, das aus der untenstehenden Liste von Werten ausgewählt wird.</p>

<h3 id="Values" name="Values">Werte</h3>

<dl>
 <dt><code>normal</code></dt>
 <dd>Aufeinanderfolgende Leerzeichen fallen zusammen. Zeilenumbruch-Zeichen im Quellcode werden als andere Leerzeichen gehandhabt. Bricht Zeilen notwendigen Stellen um und füllt die Zeile.</dd>
 <dt><code>nowrap</code></dt>
 <dd>Wie <code>normal</code>, aber unterdrückt Zeilenumbrüche im Text.</dd>
 <dt><code>pre</code></dt>
 <dd>Aufeinanderfolgende Leerzeichen bleiben erhalten, Zeilen werden nur an Zeilenumbruch-Zeichen im Quellcode und an  {{HTMLElement("br")}}-Elementen gebrochen.</dd>
 <dt><code>pre-wrap</code></dt>
 <dd>Aufeinanderfolgende Zwischenraumzeichen bleiben erhalten. Zeilen werden an Zeilenumbruch-Zeichen, an {{HTMLElement("br")}} und an notwendigen Stellen um die Zeile zu füllen umgebrochen.</dd>
 <dt><code>pre-line</code></dt>
 <dd>Aufeinanderfolgende Zwischenraumzeichen fallen zusammen. Zeilen werden an Zeilenumbruch-Zeichen, an {{HTMLElement("br")}} und an notwendigen Stellen um die Zeile zu füllen umgebrochen.</dd>
 <dt><code>break-spaces</code></dt>
 <dd> Das Verhalten ist bis auf eine Ausnahme identisch mit <code>pre-line</code>:
 <ul>
  <li>Jede Sequenz von erhaltenen Zwischenraumzeichen nimmt immer Platz ein, auch am Ende der Zeile.</li>
  <li>Nach jedem enthaltenen Zwischenraumzeichen besteht die Möglichkeit eines Zeilenumbruchs, auch zwischen Zwischenraumzeichen.</li>
  <li>Solche beibehaltenen Leerräume nehmen Platz in Anspruch und beeinflussen somit die intrinsischen Größen der Box (Min-Inhaltsgröße und Max-Inhaltsgröße).</li>
 </ul>
 </dd>
</dl>

<p>Die folgende Tabelle fasst das Verhalten der verschiedenen <code>white-space</code> Zwischenraumzeichen zusammen:</p>

<table class="standard-table">
 <thead>
  <tr>
   <th></th>
   <th>Neue Zeilen</th>
   <th>Leerzeichen und Tabulatoren</th>
   <th>Textumbruch</th>
   <th>Zeilenende-Raum</th>
  </tr>
 </thead>
 <tbody>
  <tr>
   <th><code>normal</code></th>
   <td>Fallen zusammen</td>
   <td>Fallen zusammen</td>
   <td>Umbruch</td>
   <td>Entfernt</td>
  </tr>
  <tr>
   <th><code>nowrap</code></th>
   <td>Fallen zusammen</td>
   <td>Fallen zusammen</td>
   <td>Kein Umbruch</td>
   <td>Entfernt</td>
  </tr>
  <tr>
   <th><code>pre</code></th>
   <td>Bleiben erhalten</td>
   <td>Bleiben erhalten</td>
   <td>Kein Umbruch</td>
   <td>Entfernt</td>
  </tr>
  <tr>
   <th><code>pre-wrap</code></th>
   <td>Bleiben erhalten</td>
   <td>Bleiben erhalten</td>
   <td>Umbruch</td>
   <td>hängend</td>
  </tr>
  <tr>
   <th><code>pre-line</code></th>
   <td>Bleiben erhalten</td>
   <td>Fallen zusammen</td>
   <td>Umbruch</td>
   <td>Entfernt</td>
  </tr>
  <tr>
   <th><code>break-space</code></th>
   <td>Bleiben erhalten</td>
   <td>Bleiben erhalten</td>
   <td>Umbruch</td>
   <td>Umbruch</td>
  </tr>
 </tbody>
</table>

<h2 id="Formale_Definition">Formale Definition</h2>

<p>{{CSSInfo}}</p>

<h2 id="Formale_Syntax">Formale Syntax</h2>

<pre class="syntaxbox notranslate">{{CSSSyntax}}</pre>

<h2 id="Examples" name="Examples">Beispiele</h2>

<h3 id="Einfaches_Beispiel">Einfaches Beispiel</h3>

<pre class="brush: css notranslate">code {
  white-space: pre;
}</pre>

<h3 id="Line_breaks_inside_pre_elements" name="Line_breaks_inside_pre_elements">Zeilenumbrüche innerhalb von &lt;pre&gt; Elementen</h3>

<pre class="brush: css notranslate">pre {
  word-wrap: break-word;      /* IE 5.5-7 */
  white-space: pre-wrap;      /* Modern browsers */
}</pre>

<h3 id="In_Aktion">In Aktion</h3>

<h4 id="HTML">HTML</h4>

<div class="hidden" id="In_action">
<pre class="brush: html notranslate">&lt;div id="css-code" class="box"&gt;
  p { white-space:
  &lt;select&gt;
    &lt;option&gt;normal&lt;/option&gt;
    &lt;option&gt;nowrap&lt;/option&gt;
    &lt;option&gt;pre&lt;/option&gt;
    &lt;option&gt;pre-wrap&lt;/option&gt;
    &lt;option&gt;pre-line&lt;/option&gt;
    &lt;option&gt;break-spaces&lt;/option&gt;
  &lt;/select&gt; }
&lt;/div&gt;
&lt;div id="results" class="box"&gt;
  &lt;p&gt;    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.&lt;/p&gt;
&lt;/div&gt;</pre>

<pre class="brush: css notranslate">.box {
  width: 300px;
  padding: 16px;
  border-radius: 10px;
}

#css-code {
  background-color: rgb(220, 220, 220);
  font-size: 16px;
  font-family: monospace;
}

#css-code select {
  font-family: inherit;
}

#results {
  background-color: rgb(230, 230, 230);
  overflow-x: scroll;
  height: 400px;
  white-space: normal;
  font-size: 14px;
}</pre>

<pre class="brush: js notranslate">var select  = document.querySelector("#css-code select");
var results = document.querySelector("#results p");
select.addEventListener("change", function(e) {
  results.setAttribute("style", "white-space: "+e.target.value);
})</pre>
</div>

<pre class="brush: html notranslate">&lt;p&gt; 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.&lt;/p&gt; </pre>

<h4 id="Ergebnis">Ergebnis</h4>

<p>{{EmbedLiveSample("In_action", "100%", 500)}}</p>

<h2 id="Specifications" name="Specifications">Spezifikationen</h2>

<table class="standard-table">
 <thead>
  <tr>
   <th scope="col">Spezifikation</th>
   <th scope="col">Status</th>
   <th scope="col">Kommentar</th>
  </tr>
 </thead>
 <tbody>
  <tr>
   <td>{{SpecName('CSS3 Text', '#white-space', 'white-space')}}</td>
   <td>{{Spec2('CSS3 Text')}}</td>
   <td>Präzisiert den Umbruch-Algorithmus. Äußerlich bewirkt der <code>white-space</code> eine kompakte Eigenschaft.</td>
  </tr>
  <tr>
   <td>{{SpecName('CSS2.1', 'text.html#white-space-prop', 'white-space')}}</td>
   <td>{{Spec2('CSS2.1')}}</td>
   <td>Ursprüngliche Definition</td>
  </tr>
 </tbody>
</table>

<h2 id="Browser_compatibility" name="Browser_compatibility">Browser Kompatibilität</h2>

<div class="hidden">Die Kompatibilitätstabelle auf dieser Seite wird aus strukturierten Daten generiert. Wenn Sie zu den Daten beitragen möchten, besuchen Sie bitte <a href="https://github.com/mdn/browser-compat-data">https://github.com/mdn/browser-compat-data</a> und senden Sie uns eine Pull-Anfrage.</div>

<p>{{Compat("css.properties.white-space")}}</p>

<h2 id="Siehe_auch">Siehe auch</h2>

<ul>
 <li>Eigenschaften, die definieren, wie Wörter umgebrochen werden: {{CSSxRef("overflow-wrap")}}, {{CSSxRef("word-break")}}, {{CSSxRef("hyphens")}}</li>
</ul>