w3c / w3c/csswg-drafts

[css-text] Indent-preserving wrapping

Open
#8,733 11 comments 52 reactions 1 assignee View on GitHub

@frivoal is already working on this.

Since Sep 20, 2023.

Agenda+ css-text-4
Dominant language
Bikeshed
Stars
4.9k
Forks
816
PR merge metrics
PR metrics pending

Description

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.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.