Skip to content

[css-text] Indent-preserving wrapping #8733

Open
@jakearchibald

Description

@jakearchibald

Taking some preformated content like:

<div>
  <p>
    This is a really long paragraph so you'd expect some form of wrapping
    <span>
      but there are lots of different ways of handling that.
    </span>
  </p>
</div>

Currently, white-space: pre-wrap lets you wrap it like this:

<div>                                  |
  <p>                                  |
    This is a really long paragraph so |
you'd expect some form of wrapping     |
    <span>                             |
      but there are lots of different  |
ways of handling that.                 |
    </span>                            |
  </p>                                 |
</div>                                 |

But, with code and markup, wrapping like this is much better:

<div>                                  |
  <p>                                  |
    This is a really long paragraph so |
    you'd expect some form of wrapping |
    <span>                             |
      but there are lots of different  |
      ways of handling that.           |
    </span>                            |
  </p>                                 |
</div>                                 |

…where the indenting of each line is preserved. Here's a demo of the behaviour.

This behaves as if each soft wrap repeats the whitespace from the start of the line (although this wouldn't appear in copied text).

It'd be nice if CSS could enable this.

Metadata

Metadata

Assignees

Labels

Agenda+ LaterLower-priority items that are flagged for CSSWG discussioncss-text-4

Type

No type

Projects

Status

Friday Morning

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions