News for hackers. Stuff that matters.
Re:The `hanging-punctuation property` in CSS by chrismorgan on Tuesday November 28, 2023 @02:09AM (#38443237)
I’ve been tending towards the opinion that features like this are a bad idea: that we might be better served by a general “this is prose” signal that triggers things like Knuth-Plass line-breaking, partially-hung punctuation (not full, please not full, it’s awful), conservative hyphenation, maybe even spacing and stretching tweaks to reduce the need of hyphenation (like the CTAN microtype package provides), whatever else the user agent supports. Bundle it all up in an all/auto/none property that defaults to auto, and let browsers choose heuristics for normal content. (OK, so I wouldn’t limit it quite that hard, I’d make it a little more like font-variant, but I do believe the default should be heuristic-based rather than disabled.)
Re:The `hanging-punctuation property` in CSS by jahewson on Tuesday November 28, 2023 @02:33AM (#38443345)
But then you lose backwards compatibility and have no standard spec.
Re:The `hanging-punctuation property` in CSS by chrismorgan on Tuesday November 28, 2023 @04:43AM (#38444107)
The compatibility hazard is negligible; hanging punctuation is the main one that can actually cause harm if misapplied, and conservative heuristics for enabling it are easily arrived at.

You might be surprised at how little of browsers’ existing functionality in these areas is actually defined, or in progressive cases how much is defined as being up to the browser.

When I mention things like Knuth-Plass: all current browsers use a greedy first-fit line-breaking algorithm, but IE actually had something better long ago in some situation (I forget), and until recently, the entire thing was simply undefined. Now, the default is declared to be UA-defined (text-wrap-style: auto) <https://www.w3.org/TR/css-text-4/#text-wrap-style> with the option to declare a preference for alternative modes like stable, balanced or pretty. Long before this, Firefox had a bug open about implementing Knuth-Plass or similar <https://bugzilla.mozilla.org/show_bug.cgi?id=630181>, and the only oppositions have been on technical implementation grounds, not that there’s anything wrong with the concept, which people generally agree is desirable.

As regards heuristics, you can define the heuristics to use completely, or you can leave it to browsers with some suggestions, or you can leave it to browsers. There’s plenty of precedent for all three of these.

Re:The `hanging-punctuation property` in CSS by epeus on Tuesday November 28, 2023 @06:13AM (#38444582)
The Microsoft trigger was `text-justify: newspaper` and intended for fully-justified narrow columns. I don't think it made it to Edge.
Re:The `hanging-punctuation property` in CSS by WorldMaker on Tuesday November 28, 2023 @03:15PM (#38450649)
I believe it made it to Spartan Edge but not the switch to Chromium Edge.
Re:The `hanging-punctuation property` in CSS by gwern on Tuesday November 28, 2023 @12:24PM (#38448238)
> hanging punctuation is the main one that can actually cause harm if misapplied

Yeah, it can screw with layout. We recently removed it because it had seemed harmless to have it enabled so Safari users could enjoy it and other browsers would just ignore it, but then we discovered it was screwing up the layout on the main page's lists (https://gwern.net/index) and was not harmless after all. :(

Re:The `hanging-punctuation property` in CSS by layer8 on Tuesday November 28, 2023 @10:06AM (#38446486)
It’s not like CSS implementations have been particularly strong in maintaining backwards compatibility.
Re:The `hanging-punctuation property` in CSS by qaisjp on Tuesday November 28, 2023 @03:15AM (#38443535)
Interesting opinion. Why?
Re:The `hanging-punctuation property` in CSS by chrismorgan on Tuesday November 28, 2023 @04:25AM (#38443999)
If these things are a good idea, they should be applied generally. Depending on individual sites to apply them, and individually at that, means that most sites will never get them, and that the “best practice” has an ever-increasing weight and burden over time.
Re:The `hanging-punctuation property` in CSS by chilmers on Tuesday November 28, 2023 @05:42AM (#38444423)
The problem is, changes to the web platform need to be backward compatible. You can't make a global change without potentially breaking existing content. In this case, you could easily end up triggering scrolling in a bunch of places, or with punctuation being invisible or looking bad. So it has to be opt-in.
Re:The `hanging-punctuation property` in CSS by chrismorgan on Tuesday November 28, 2023 @06:09AM (#38444564)
Refer to my response to jahewson. You can easily apply this to the vast majority of content with negligible hazard.
Re:The `hanging-punctuation property` in CSS by globular-toast on Tuesday November 28, 2023 @02:29AM (#38443327)
I agree. On my e-reader I can choose to enable hanging punctuation. Why should a web developer be able to or be expected to make that choice for me?
Re:The `hanging-punctuation property` in CSS by lwhi on Tuesday November 28, 2023 @03:04AM (#38443485)
A web developer shouldn't, but a designer should.

Otherwise, why bother with design?

Re:The `hanging-punctuation property` in CSS by marginalia_nu on Tuesday November 28, 2023 @08:53AM (#38445673)
How would you distinguish between web design and development?
Re:The `hanging-punctuation property` in CSS by lwhi on Tuesday November 28, 2023 @12:35PM (#38448380)
How it's built vs what it looks like.
Re:The `hanging-punctuation property` in CSS by marginalia_nu on Tuesday November 28, 2023 @01:34PM (#38449353)
That's arguably a very limited view of design. Design is far more than aesthetics.
Re:The `hanging-punctuation property` in CSS by lwhi on Tuesday November 28, 2023 @01:50PM (#38449598)
Design is visual engineering .. development is software engineering.

Both essentially involve solving problems.

Re:The `hanging-punctuation property` in CSS by marginalia_nu on Tuesday November 28, 2023 @02:05PM (#38449833)
I don't think this agrees with how the term is used. I've never heard of anyone being said to design a painting or a sculpture. Meanwhile, engineers are said to design things that aren't visible, such as algorithms or a circuits.
Re:The `hanging-punctuation property` in CSS by lwhi on Tuesday November 28, 2023 @03:39PM (#38450967)
We're talking about web design.

If we consider art .. sculpture and painting do require planning, preparatory sketches or a maquette. Design thinking allows us to build and solve.

Re:The `hanging-punctuation property` in CSS by marginalia_nu on Tuesday November 28, 2023 @03:42PM (#38451012)
I don't see any obvious reason why design should come to mean pure aesthetics in this particular domain, and even if we do, what word is left to mean actual design work in the traditional sense of the word?
Re:The `hanging-punctuation property` in CSS by lwhi on Wednesday November 29, 2023 @07:38AM (#38458638)
It doesn't mean pure aesthetics .. the way something looks affects it's affordance.
Re:The `hanging-punctuation property` in CSS by Sharlin on Tuesday November 28, 2023 @03:39AM (#38443665)
Why should the typesetter of a dead-tree book be able or be expected to make that choice for me?
Re:The `hanging-punctuation property` in CSS by neoberg on Tuesday November 28, 2023 @04:21AM (#38443955)
Because it's impossible while it's not in the digital medium?
Re:The `hanging-punctuation property` in CSS by charcircuit on Tuesday November 28, 2023 @03:05AM (#38443488)
For the same reason a web page can choose what font to use even of your ereader has a feature to change fonts.
Re:The `hanging-punctuation property` in CSS by tannhaeuser on Tuesday November 28, 2023 @04:42AM (#38444096)
Don't tell the CSS zealots, but mainstream eBook readers (for the XHTML-based EPUB) basically throw the CSS away and reflow everything anyway based on a generic prose style with a heavily optimized serif and user preferences for font size. Most importantly, they're applying proper hyphenation and justification, as expected by book readers and unsupported by CSS for a much better reading experience compared to browsers. The extent of this might not be readily apparent in English language publications (with relatively short words and long phrases), but in German almost every other line has hyphenated words at the end (and I'm guessing in other languages with long composed words such as Finnish or Hungarian as well). EPUB uses extra tags for eg. spreading (responsive layout) anyway.

Reading EPUB 3 specs is almost comical when compared with the feature set of real world EPUB publications and reader software: CSS trickery (such as pointless SVG wrappers around raster images), yet not using floated elements even for the few cases where it's a good fit (initials, flowed images), using Unicode quotations and mdash/ndash, not using CSS paged media for pagination and line numbering, EPUB 3 reference examples crashing reader software, Amazon and Apple using proprietary EPUB extensions for these reasons anyway (and having good technical reason to) while not contributing to W3C, Inc's spec., ...

The last useful EPUB spec version appears to be 3.0. from 2014 before IDPF merged into W3C, Inc. Later versions reference the "HTML living standard" and CSS snapshots (with CSS-everything that no reader software is going to support, ever). To bring old reference examples into compliance with 3.3/epubcheck, the only thing the WG bothered to do was to put secondary headings into <p> elements where they used <h2> in <hgroup> to match the changed spec (removal of the so-called HTML outlining algorithm). Great so this makes the reference examples nominally conformant, but leaves the installed base of eBooks out there without backward compatibility (and e-readers are far from evergreen browsers). Not that it matters anyway: calibre's conversion manpage strongly recommends and defaults to EPUB 2 anyway, supporting EPUB 3 only since 2019. In a way, EPUB 3.3 with its generic forward compat reads like the last spec its authors intend to publish, before the major organizational and funding changes at W3C, Inc in 2023.

I'm seriously beginning to wonder if PDF is the better format for reading and archival after all as 7+ inch reading devices become the norm (or don't they?)

Re:The `hanging-punctuation property` in CSS by chrismorgan on Tuesday November 28, 2023 @04:57AM (#38444169)
> as […] unsupported by CSS

Actually, slap `hyphens: auto` onto the CSS (since its default value is `manual`), and whatever your ebook reader does for things like hyphenation and justification is almost certainly spec-compliant, because all of that stuff is explicitly UA-defined these days.

Re:The `hanging-punctuation property` in CSS by p4bl0 on Tuesday November 28, 2023 @04:36AM (#38444071)
The thing is, we cannot think of CSS being just for the browser anymore. More and more stuff are being typesetted or presented/designed using CSS: mobile and desktop applications UI, graphic design (the SVG vector format standard uses CSS), as well as all sorts of printed materials. Whether this is a good idea or not is another question, but it's a fact. So CSS kind of has to offer fine-tuned control over many things including tiny details.

See for example Paged.js [1], a way to use HTML and CSS to produce printed books, with complete control over the rendering and an attention to details almost of TeX level's. Using web technologies as source format tremendously facilitates the production of various electronic formats in addition to the printed/PDF version, such as ePub and well, web pages, which need free flow text that print-oriented format do not allow for obvious reasons.

All this to say, I agree with your feeling if we stick to web browsers, but CSS is so much more nowadays.

[1] https://pagedjs.org/

Re:The `hanging-punctuation property` in CSS by chrismorgan on Tuesday November 28, 2023 @04:54AM (#38444155)
CSS specs are explicitly not interested in prescribing TeX-level control; text-wrap-style is a good example of this: it’s just hints, with the actual algorithms completely UA-defined. And in fact, they’re going out of their way to recommend including multiple distinct heuristics of prettiness, so that developers don’t use it as a proxy for just one thing and start relying on something that is explicitly and deliberately undefined. <https://github.com/w3ctag/design-reviews/issues/864#issuecom...> (And Chromium has done just this: <https://bugs.chromium.org/p/chromium/issues/detail?id=143279...>.)

In other words: you’ve already lost!

Re:The `hanging-punctuation property` in CSS by p4bl0 on Tuesday November 28, 2023 @05:08AM (#38444231)
I understand this, but let's be more concrete: when you use CSS to design for print (that is, in general, to produce a PDF), you are using a specific implementation (e.g., Firefox will be used to produce the final PDF from your HTML and CSS, or Inkscape will be from your SVG and CSS). Given an implementation, you get a determined rendering, and it is this specific one that you need to be able to tweak to your needs. Same goes for application UI design: a given GUI framework comes with its own implementation of CSS rendering and it is its specific output that developers (or rather, theme designers) need to be able to have precise control over. In both cases, even if the standard does not precisely states what property values must give what rendering, you get something using the tools you have and you may want to tweak details to your taste using those same tools (even if only by trial and "error", but for that you need the option to fine tune the properties you want to play with).

Again, I'm not saying CSS is coherent nor that this is a good thing in the absolute sense, as I already said, I agree with your feeling, I'm just saying that I understand where the need of more precise control/tweaking over details that is sometime in the standard comes from.

Re:The `hanging-punctuation property` in CSS by chrismorgan on Tuesday November 28, 2023 @05:10AM (#38444246)
You’re abusing CSS.

(Can’t say I never have…)

Re:The `hanging-punctuation property` in CSS by p4bl0 on Tuesday November 28, 2023 @05:14AM (#38444267)
Well I'm not, but some people are, probably. The need exists. That's my whole point :).
Re:The `hanging-punctuation property` in CSS by jjgreen on Tuesday November 28, 2023 @07:39AM (#38445052)
HTML tables for layout FTW.
Re:The `hanging-punctuation property` in CSS by gazook89 on Tuesday November 28, 2023 @09:28AM (#38446056)
One example that I contribute to: https://homebrewery.naturalcrit.com

It is a code mirror app that outputs md styled like dnd books. It’s very much a “round peg in square hole” project, using html/css to create print materials, but for many it is good enough. It is just html and css, and allows customization, and precise styling requires precise css properties.

As you noted, it does only work well in one browser, Chrome on desktop (even though I think all the devs use FF as their daily driver). But as another commenter noted, the answer is that you design on one machine and share via pdf.

Re:The `hanging-punctuation property` in CSS by eropple on Tuesday November 28, 2023 @09:32AM (#38446100)
This is ridiculously well-done. Thanks for sharing.
Re:The `hanging-punctuation property` in CSS by DemocracyFTW2 on Tuesday November 28, 2023 @03:14PM (#38450631)
> You’re abusing CSS.

In the spirit of "not a bug but a feature" I'd say they use is demonstrating the "full potential" of CSS...

Re:The `hanging-punctuation property` in CSS by postmodest on Tuesday November 28, 2023 @10:22AM (#38446638)
Part of the perversion is that web standards demand "more than one implementation" (see WebSQL) so if we did the same thing and just "put TeX in the layout pipeline" that would get punted faster than SQLite was.

Text layouts being undefined is the last great tragedy of HTML, and we should fix it.

Re:The `hanging-punctuation property` in CSS by fvdessen on Tuesday November 28, 2023 @05:19AM (#38444296)
I once implemented a knuth style renderer to properly typeset books into html. IMHO If you want to do advanced typography you need to algorithmically set the width and offsets of spans and use spacer elements. Otherwise all that complexity has to go into the css spec and that will be a lot for what is otherwise a niche use-case. Another problem is that good typography is algorithmically expensive and is best computed ahead of time, rather than on page load.
Re:The `hanging-punctuation property` in CSS by SigmundurM on Tuesday November 28, 2023 @09:37AM (#38446160)
Electronic books (EPUBs) are literally just HTML, CSS (plus some more standards specific to EPUBs).
Re:The `hanging-punctuation property` in CSS by chrisfinazzo on Tuesday November 28, 2023 @11:07AM (#38447232)
Oh, tadpole...

I was once like you, thinking like "It's the web! I know this!" Turns out, no...actually you don't. I've been soaking in this for a couple weeks, trying to rid my life of the last few Word documents that I use frequently and haven't converted.

Writing HTML to mimic print layout is a bit creaky, but it's trivial compared to the kinds of shenanigans that EPUB often requires.

Despite what you might tell yourself, reader applications are not web browsers, and come with their own set of idiosyncrasies and corner cases, and will gladly barf all over your HTML or (worse) sit still and refuse to move no matter how much you cajole them.

https://getyarn.io/yarn-clip/34d4f471-2bf6-4e55-ba95-1419f20...

If web standards sometimes make you feel like ants trying to reach the top of a hill with bits of grain, EPUB might as well be rolling Sisyphus' boulder.

"It is not the web, it's the web as rendered by a schizophrenic, half crazed hamster in a wheel"

-John Siracusa

Re:The `hanging-punctuation property` in CSS by neves on Tuesday November 28, 2023 @10:27AM (#38446675)
Well, Kindle books are formatted with CSS
Re:The `hanging-punctuation property` in CSS by Vt71fcAqt7 on Tuesday November 28, 2023 @11:41AM (#38447692)
+1 for padgedjs. I wish browsers would just implement @page on their own though.
Re:The `hanging-punctuation property` in CSS by uxp8u61q on Tuesday November 28, 2023 @07:07AM (#38444863)
The "prose" signal exists, it's called the <p> HTML tag.
Re:The `hanging-punctuation property` in CSS by marginalia_nu on Tuesday November 28, 2023 @08:52AM (#38445663)
That's p as in paragraph. <p> also has some honestly pretty weird end-tag omission rules that makes it very unsuitable for any other semantic than demarcating a paragraph.
Re:The `hanging-punctuation property` in CSS by uxp8u61q on Tuesday November 28, 2023 @09:37AM (#38446169)
A paragraph... of what? Just think about it for a minute...
Re:The `hanging-punctuation property` in CSS by marginalia_nu on Tuesday November 28, 2023 @10:34AM (#38446783)
Of any sort of text, including but not limited to prose.
Re:The `hanging-punctuation property` in CSS by uxp8u61q on Tuesday November 28, 2023 @10:50AM (#38446992)
I don't know what you call "prose", but something that needs to be split into paragraphs is called prose in my book. Maybe you've been misusing the <p> tag? Can you describe a situation where you've used the <p> tag that wasn't "prose"?
Re:The `hanging-punctuation property` in CSS by marginalia_nu on Tuesday November 28, 2023 @11:07AM (#38447220)
Anything on verse for one.
Re:The `hanging-punctuation property` in CSS by uxp8u61q on Tuesday November 28, 2023 @11:24AM (#38447445)
That's a joke, right?
Re:The `hanging-punctuation property` in CSS by Someone on Tuesday November 28, 2023 @07:51AM (#38445130)
> a general “this is prose” signal that triggers things like […] conservative hyphenation

At the least, that requires specifying the language of the text, probably even subtle differences such as those between UK and US english (although those can probably be handled very conservatively most of the time, as long words are fairly rare in English, compared to, say, Dutch or German)

Re:The `hanging-punctuation property` in CSS by chrismorgan on Tuesday November 28, 2023 @08:53AM (#38445674)
`hyphens: auto` is already language-aware. (It’s just that currently it either does nothing or too much, because the first-fit line breaking algorithm is lousy for hyphenation.)
Re:The `hanging-punctuation property` in CSS by westurner on Tuesday November 28, 2023 @09:36AM (#38446156)
Is there a CSS setting for links not wrapping and instead being justified to a new line on Android devices?

Input:

  - URL1
    - URL2
      - https://longurl3
Output:

  - URL1
    - URL2
      -
  https://longurl3