5 ms·
> Soft Wrapping vs Hard Wrapping This is actually one of HTML's most underrated features - there is no distinction between hard and soft wrapping. Any whitespa
by wavemode 2y ago
> Soft Wrapping vs Hard Wrapping
This is actually one of HTML's most underrated features - there is no distinction between hard and soft wrapping. Any whitespace, of any form and quantity, between any two words is just converted to a single space in the rendered output.
Thus the developer, in a code editor, is free to hard wrap and indent the text in whatever way makes the most visual sense. Meanwhile in the rendered output the actual wrapping that occurs (if any) is controlled by the stylesheet.
I wish more programming languages had multiline string syntax that could do this (automatically remove all newlines and indentation). It turns out to be quite useful in a variety of domains.
- playingalong 2y agoUseful? Yes. But then you need some way to provide the exact indentation/spacing in some cases. And the easiest is to provide them verbatim.
- SoftTalker 2y agoHTML has the "pre" element that does this.
- jbaber 2y agopre does a lot more than respect newlines.
- arp242 2y ago"white-space:pre-line" in CSS should make it only break on hard enters. There are a bunch of values; see e.g. MDN. Can be used on any element of course, not just <pre>.
- bastawhiz 2y agoNo? https://searchfox.org/mozilla-central/source/layout/style/res/html.css https://searchfox.org/mozilla-central/source/layout/style/re... The Firefox default style sets a fixed width font and sets a small margin. What's "a lot more"?
- macintux 2y agoA few years ago I was auto-generating HTML to ingest into an older version of Confluence (pretending it was Markdown). Confluence behaved differently (correctly) when I inserted hard line breaks between elements. Took a while to figure that one out.