[css-text] Collapsing whitespace at the end of a line

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

[css-text] Collapsing whitespace at the end of a line

Tab Atkins Jr.
According to <https://drafts.csswg.org/css-text/#collapse>, whitespace
preceding a segment break is removed.  However, it appears that
browsers instead collapse it to one space.

Here's an example using 'white-space':

<div style="white-space: pre-line;">a
z</div>

(Just in case the email client trims things, there's a space at the
end of the first line, after the "a".)

Here's an example using <br>:

<div style="white-space: pre-line;">a <br>z</div>

In both of these examples, if you highlight the "a" and then drag
slightly rightward, you'll see it highlight a space character as well.
This happens in both Chrome and Firefox.

This sgugests that browsers are not following the "preceding" part of
step 1 in that section, and are instead falling down to step 4, where
runs of spaces are collapsed down to a single visible space.

Is there a particular reason for this?  Should we adjust the spec to
match implementations, or file bugs on implementations to match the
spec?

~TJ

Reply | Threaded
Open this post in threaded view
|

Re: [css-text] Collapsing whitespace at the end of a line

fantasai
On 09/10/2015 01:36 PM, Tab Atkins Jr. wrote:

> According to <https://drafts.csswg.org/css-text/#collapse>, whitespace
> preceding a segment break is removed.  However, it appears that
> browsers instead collapse it to one space.
>
> Here's an example using 'white-space':
>
> <div style="white-space: pre-line;">a
> z</div>
>
> (Just in case the email client trims things, there's a space at the
> end of the first line, after the "a".)
>
> Here's an example using <br>:
>
> <div style="white-space: pre-line;">a <br>z</div>
>
> In both of these examples, if you highlight the "a" and then drag
> slightly rightward, you'll see it highlight a space character as well.
> This happens in both Chrome and Firefox.
>
> This sgugests that browsers are not following the "preceding" part of
> step 1 in that section, and are instead falling down to step 4, where
> runs of spaces are collapsed down to a single visible space.
>
> Is there a particular reason for this?  Should we adjust the spec to
> match implementations, or file bugs on implementations to match the
> spec?

I'm inclined to file bugs on implementations to match the spec,
since that seems like kinda weird behavior. Why preserve the
space before the break but not after it? o_O

~fantasai

Reply | Threaded
Open this post in threaded view
|

Re: [css-text] Collapsing whitespace at the end of a line

Tab Atkins Jr.
On Wed, Aug 17, 2016 at 7:19 PM, fantasai <[hidden email]> wrote:

> On 09/10/2015 01:36 PM, Tab Atkins Jr. wrote:
>>
>> According to <https://drafts.csswg.org/css-text/#collapse>, whitespace
>> preceding a segment break is removed.  However, it appears that
>> browsers instead collapse it to one space.
>>
>> Here's an example using 'white-space':
>>
>> <div style="white-space: pre-line;">a
>> z</div>
>>
>> (Just in case the email client trims things, there's a space at the
>> end of the first line, after the "a".)
>>
>> Here's an example using <br>:
>>
>> <div style="white-space: pre-line;">a <br>z</div>
>>
>> In both of these examples, if you highlight the "a" and then drag
>> slightly rightward, you'll see it highlight a space character as well.
>> This happens in both Chrome and Firefox.
>>
>> This sgugests that browsers are not following the "preceding" part of
>> step 1 in that section, and are instead falling down to step 4, where
>> runs of spaces are collapsed down to a single visible space.
>>
>> Is there a particular reason for this?  Should we adjust the spec to
>> match implementations, or file bugs on implementations to match the
>> spec?
>
>
> I'm inclined to file bugs on implementations to match the spec,
> since that seems like kinda weird behavior. Why preserve the
> space before the break but not after it? o_O

I don't particularly care either way, tho there are cases where
trailing whitespace has some significance - for example, illustrating
markdown examples (where two trailing spaces indicates a hard
linebreak).

~TJ