Skip to content

Commit 1014e0a

Browse files
committed
[css-text-3] Clarify segments breaks and interaction with DOM/HTML
See #5147
1 parent 5abdbf4 commit 1014e0a

File tree

1 file changed

+30
-10
lines changed

1 file changed

+30
-10
lines changed

css-text-3/Overview.bs

+30-10
Original file line numberDiff line numberDiff line change
@@ -1280,28 +1280,48 @@ Order of Operations</h4>
12801280
<h2 id="white-space-processing">
12811281
White Space Processing Details</h2>
12821282

1283-
<p>The source text of a document often contains formatting
1283+
The source text of a document often contains formatting
12841284
that is not relevant to the final rendering: for example,
12851285
<a href="http://rhodesmill.org/brandon/2012/one-sentence-per-line/">breaking the source into segments</a>
12861286
(lines) for ease of editing
12871287
or adding [=white space characters=] such as [=tabs=] and [=spaces=] to indent the source code.
12881288
CSS white space processing allows the author to control interpretation of such formatting:
12891289
to preserve or collapse it away when rendering the document.
1290-
White space processing in CSS interprets [=white space characters=] only for rendering:
1290+
White space processing in CSS
1291+
(which is controlled with the 'white-space' property)
1292+
interprets [=white space characters=] only for rendering:
12911293
it has no effect on the underlying document data.
12921294

1293-
<p>White space processing in CSS is controlled with the 'white-space' property.
1295+
Note: Depending on the document language,
1296+
segments can be separated by a particular newline sequence
1297+
(such as a line feed or CRLF pair),
1298+
or delimited by some other mechanism,
1299+
such as the SGML <code>RECORD-START</code> and <code>RECORD-END</code> tokens.
12941300

1295-
<p id="segment-normalization">
1296-
CSS does not define document segmentation rules. Segments can be
1297-
separated by a particular newline sequence (such as a line feed or
1298-
CRLF pair), or delimited by some other mechanism, such as the SGML
1299-
<code>RECORD-START</code> and <code>RECORD-END</code> tokens.
1300-
For CSS processing, each document language&ndash;defined segment break
1301-
and each line feed (U+000A)
1301+
<p id="segment-normalization">
1302+
For CSS processing, each document language&ndash;defined “segment break” or “newline sequence”--
1303+
or if none are defined, each line feed (U+000A)--
13021304
in the text is treated as a <dfn export>segment break</dfn>,
13031305
which is then interpreted for rendering as specified by the 'white-space' property.
13041306

1307+
In the case of [[HTML]],
1308+
each <a href="https://html.spec.whatwg.org/#newlines">newline sequence is normalized</a> to a single line feed (U+000A)
1309+
for representation in the DOM,
1310+
so when an HTML document is represented as a [[DOM]] tree
1311+
each line feed (U+000A)
1312+
is treated as as a [=segment break=].
1313+
1314+
Note: In most common CSS implementations,
1315+
HTML does not get styled directly.
1316+
Instead, it is processed into a [[DOM]] tree,
1317+
which is then styled.
1318+
Unlike HTML,
1319+
the DOM does not give any particular meaning to carriage returns (U+000D),
1320+
so they are not treated as [=segment breaks=].
1321+
If carriage returns (U+000D) are inserted into the DOM
1322+
by means other than HTML parsing,
1323+
they then get treated as defined below.
1324+
13051325
<wpt pathprefix="/css/CSS2/text">
13061326
white-space-processing-005.xht
13071327
white-space-processing-006.xht

0 commit comments

Comments
 (0)