[csswg-drafts] Allow authors to suppress line breaks after atomic inlines (e.g. SVG formulas) (#12915)

fweth has just created a new issue for https://github.com/w3c/csswg-drafts:

== Allow authors to suppress line breaks after atomic inlines (e.g. SVG formulas) ==
When formulas are rendered as SVGs (like MathJax does), they act as atomic inlines and therefore always create soft wrap opportunities before and after themselves. The spec currently says:

> For Web-compatibility there is a soft wrap opportunity before and after each replaced element or other atomic inline, even when adjacent to a character that would normally suppress them…

and

> For soft wrap opportunities defined by the boundary between two characters or atomic inlines, the white-space property on the nearest common ancestor of the two characters controls breaking…

This causes a practical problem: you often have punctuation or a closing parenthesis right after a formula, and you don’t want a linebreak between them. Because the break after the SVG is defined to be outside of it, there’s currently no way in CSS to prevent that break without extra markup or a WORD JOINER character.

So for something like this:

```html
<p>Some text <svg class="mjx-svg">…</svg>.</p>
```

authors can’t easily say “don’t break between the SVG and the period”. Firefox currently (and probably incorrectly) suppresses that break based on the SVG’s own `white-space`, which actually gives the more useful behavior. Chrome/WebKit follow the spec and allow the break.

It would be great if CSS had a way to control line-breaking around atomic inlines, maybe an extension of `line-break`, or something like `break-around: avoid`, so you could fix this kind of “formula + punctuation” case without extra wrappers.

(KaTeX doesn’t hit this because it renders math as normal text glyphs instead of SVGs, but SVG-based math will likely stick around for a while.)

Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/12915 using your GitHub account


-- 
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config

Received on Wednesday, 8 October 2025 10:35:31 UTC