You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
At least text shouldn’t be visibly overflowing in the next column, but if we can also guarantee it will break in order to stay readable, this will be a better solution, obviously.
OK so I explored overflow: clip as it was first mentioned in #119 to see how it could solve all issues.
As a disclaimer, we’re already finding ourselves dealing with progressive enhancement and the lack of guideline/policy (issue #139) given it’s part of the 2022 baseline, with support available from Chrome 90, Firefox 80, and Safari 16.
As a spoiler, this would be an incomplete fix due to partial support of overflow-clip-margin.
Overflow content is clipped at the element's overflow clip edge that is defined using the overflow-clip-margin property. As a result, content overflows the element's padding box by the value of overflow-clip-margin or by 0px if not set. Overflow content outside the clipped region is not visible, user agents do not add a scroll bar, and programmatic scrolling is also not supported. No new formatting context is created. To establish a formatting context, use overflow: clip along with display: flow-root. The element box is not a scroll container.
My guess is flow-root may help with scroll performance if needed.
Recap
In theory, this could help solve this issue. At least in isolation in ReadiumCSS, it is working as expected as a fix – of course it’s another story in apps injecting ReadiumCSS.
Anyways, adding the following deals with all the overflow issues:
As a reference, no overflow is set and you can see the link doesn’t wrap and may flow into the next column:
Without overflow-clip-margin, this is what happens with a link that doesn’t wrap. You can still see it overflow in the “page margins” (which is padding added to columns).
With overflow-clip-margin: content-box, it works as you would expect, as the link doesn’t overflow any longer.
I’ve checked and element.scrollLeft and transform: translateX() work as expected in JS. At least it doesn’t break it.
Issues
Update: Turns out the support tables you can find on popular websites were wrong…
As far as ReadiumCSS is concerned, mainly support, which means this would fix overflow issues for the latest versions of browsers/webviews, but only partially due to the support of overflow-clip-margin:
it’s not supported in Safari/iOS It is supported in Safari/iOS
it’s only supported if overflow: clip is set for both axes in Chromium (i.e. you can’t set overflow-x: clip only)
content-box is not supported in Firefox nor Safari
As far as apps are concerned, this is unknown.
Conclusion
This is not ready for prime time, another solution should be explored. has potential as a progressive enhancement. However, this means previous versions that do not support it have to rely on overflow: hidden – it’s used in other Reading Systems though, so it’s a confirmation of sorts that it can help alleviate this issue.
@fondoger Thanks for weighing in and pointing that out.
From initial testing it created some issues and didn’t necessarily offer the best expected results, especially in hyphenated contexts.
However, it’s something that might be revisited in the future, with the implementation of version 2 in toolkits. We will have to pay a particular attention to the overflow issue for practical reasons so I’m expecting additional effort being spent in the upcoming weeks.
I am not a developer, so I cannot precisely say how to fix it. I am just a reader, and I use Aldiko, where I had faced this issue. On contacting Aldiko, they pointed me here.
But I have faced this issue only on readium based apps, like Aldiko and Thorium.
Same epub files on other open-source apps like calibre do not face this issue. Perhaps you could check how they have implemented it?
Also, after looking up a bit, doesn't overflow-clip, well, clip off the overflowing words? That doesn't seem very helpful for reading. As I said earlier, calibre deals with this by wrapping the overflowing text onto the next line, and so do commercial apps like Play Books, Kindle and Kobo. Is something similar not possible here?
I read earlier that someone suggested break-word as a possible solution. The response was that it caused problems in some special “hyphenated contexts”. I get that edge cases exist, but losing part of the text entirely feels like a much bigger issue. Can’t the wrapping be fixed first, and edge cases handled later?
Sorry I’ve had very little time available for ReadiumCSS due to work being done in other Readium-related projects. I’m only catching up just now.
Same epub files on other open-source apps like calibre do not face this issue. Perhaps you could check how they have implemented it?
Believe it or not but what is already in place for dealing with this was heavily inspired by other apps as we needed to keep things consistent as well for publishers/authors/ebook designers.
But a lof of apps/distributors are also modifying files to solve various issues – something ReadiumCSS can’t do because it’s just a library of stylesheets making its best effort to apply styles on top of the ones in the publication.
Also, after looking up a bit, doesn't overflow-clip, well, clip off the overflowing words?
This is only part of the improvements meant to solve different issues e.g. large tables for instance, as they are overflowing into the next page currently. There, ReadiumCSS can’t do miracles, app developers have to implement something to handle that smartly e.g. displaying a simpler preview and making tables zoomable, etc.
I can reassure you I’m not seeing this as a good-enough fix for long words, far from it.
We actually have planned a round of Research and Development to see if the situation is any better than the last time we tried so I’ll keep participants updated here.
Adding a measurement from a reading system that hit this, in case the pagination side is useful for the planned R&D round.
We paginate with multicol in a WKWebView, one column of 100vw by 100vh. The part that surprised us was not that the box overflows, but that the overflow does not extend the scroll extent. document.documentElement.scrollWidth stays at
exactly innerWidth in every failing case, the same value it reports when nothing overflows at all.
A reading system deriving its page count from the scroll extent, in the shape (scrollWidth + colGap) / (innerWidth + colGap), therefore never produces a page covering the overflowing content. So it is not only that the text is clipped or bleeds into the next column: there is no page the reader can turn to that would reveal it, and the reading system reports a book shorter than its own content.
Measured at 320x480 CSS px, 280px of usable column, the same 120-character unbroken run inside each shape:
markup
box width
escapes
<p>
278
no
<pre>
278
no
<td>
810
yes
display: inline-block
826
yes
author a { white-space: nowrap }
810
yes
The paragraph rows pass because word-wrap: break-word at ReadiumCSS-before.css:486 breaks against the line box. The failing rows are decided by min-content intrinsic sizing instead, which break-word explicitly does not affect per CSS Text 3, and which max-width at :523 cannot reduce below. overflow-wrap: anywhere is the value that does reduce min-content sizing, if that is worth including in the round.
A public reproducer, since the earlier reports here could not share files: Project Gutenberg ebook 20871, Human Foods and Their Nutritive Value, epub3.images edition. It has 43 tables, and in a 280px column two of its documents carry tables of 335, 330, 417, 401, 450 and 333 CSS px. Measure with offsetWidth: inside multicol, getBoundingClientRect() returns the union of an element's fragments across columns, so a merely tall table reports an enormous width.
On the table half of this we took the advice above and scale a wide table to fit one page, with a tap opening a zoomable full size view. That works well. It is the long links and inline-block boxes in running text where a reading system has less to work with.
Activity
JayPanoz commentedon Apr 24, 2024
OK so I explored
overflow: clipas it was first mentioned in #119 to see how it could solve all issues.As a disclaimer, we’re already finding ourselves dealing with progressive enhancement and the lack of guideline/policy (issue #139) given it’s part of the 2022 baseline, with support available from Chrome 90, Firefox 80, and Safari 16.
As a spoiler, this would be an incomplete fix due to partial support of
overflow-clip-margin.MDN docs
Support
Summary
My guess is
flow-rootmay help with scroll performance if needed.Recap
In theory, this could help solve this issue. At least in isolation in ReadiumCSS, it is working as expected as a fix – of course it’s another story in apps injecting ReadiumCSS.
Anyways, adding the following deals with all the overflow issues:
You need both
overflow: clipin:rootandbody.As a reference, no
overflowis set and you can see the link doesn’t wrap and may flow into the next column:Without
overflow-clip-margin, this is what happens with a link that doesn’t wrap. You can still see it overflow in the “page margins” (which ispaddingadded to columns).With
overflow-clip-margin: content-box, it works as you would expect, as the link doesn’t overflow any longer.I’ve checked and
element.scrollLeftandtransform: translateX()work as expected in JS. At least it doesn’t break it.Issues
Update: Turns out the support tables you can find on popular websites were wrong…
As far as ReadiumCSS is concerned, mainly support, which means this would fix overflow issues for the latest versions of browsers/webviews, but only partially due to the support of
overflow-clip-margin:it’s not supported in Safari/iOSIt is supported in Safari/iOSoverflow: clipis set for both axes in Chromium (i.e. you can’t setoverflow-x: cliponly)content-boxis not supported in Firefox nor SafariAs far as apps are concerned, this is unknown.
Conclusion
This
is not ready for prime time, another solution should be explored.has potential as a progressive enhancement. However, this means previous versions that do not support it have to rely onoverflow: hidden– it’s used in other Reading Systems though, so it’s a confirmation of sorts that it can help alleviate this issue.fondoger commentedon Aug 22, 2024
Does the below code resolve the issue?
JayPanoz commentedon Aug 28, 2024
@fondoger Thanks for weighing in and pointing that out.
From initial testing it created some issues and didn’t necessarily offer the best expected results, especially in hyphenated contexts.
However, it’s something that might be revisited in the future, with the implementation of version 2 in toolkits. We will have to pay a particular attention to the overflow issue for practical reasons so I’m expecting additional effort being spent in the upcoming weeks.
SH-github0 commentedon Apr 30, 2025
Hey! Will this issue be ever resolved?
JayPanoz commentedon Apr 30, 2025
@SH-github0 In version 2,
overflow-cliphas been implemented as a progressive enhancement.Other than that, the safeguards’ selector for long strings has been slightly improved but, as always, the limitation lies in the publication’s markup – which is the reason it is a frustratingly complex issue to solve.
Note the safeguard is not using
!importantso that it can be disabled in order to use another option, should authors/publishers want to do that.But if we are talking about a bulletproof solution, I’m afraid we have not been able to find that yet.
SH-github0 commentedon Apr 30, 2025
I am not a developer, so I cannot precisely say how to fix it. I am just a reader, and I use Aldiko, where I had faced this issue. On contacting Aldiko, they pointed me here.
But I have faced this issue only on readium based apps, like Aldiko and Thorium.
Same epub files on other open-source apps like calibre do not face this issue. Perhaps you could check how they have implemented it?
SH-github0 commentedon May 3, 2025
Also, after looking up a bit, doesn't
overflow-clip, well, clip off the overflowing words? That doesn't seem very helpful for reading. As I said earlier, calibre deals with this by wrapping the overflowing text onto the next line, and so do commercial apps like Play Books, Kindle and Kobo. Is something similar not possible here?I read earlier that someone suggested
break-wordas a possible solution. The response was that it caused problems in some special “hyphenated contexts”. I get that edge cases exist, but losing part of the text entirely feels like a much bigger issue. Can’t the wrapping be fixed first, and edge cases handled later?JayPanoz commentedon May 12, 2025
Sorry I’ve had very little time available for ReadiumCSS due to work being done in other Readium-related projects. I’m only catching up just now.
Believe it or not but what is already in place for dealing with this was heavily inspired by other apps as we needed to keep things consistent as well for publishers/authors/ebook designers.
But a lof of apps/distributors are also modifying files to solve various issues – something ReadiumCSS can’t do because it’s just a library of stylesheets making its best effort to apply styles on top of the ones in the publication.
This is only part of the improvements meant to solve different issues e.g. large tables for instance, as they are overflowing into the next page currently. There, ReadiumCSS can’t do miracles, app developers have to implement something to handle that smartly e.g. displaying a simpler preview and making tables zoomable, etc.
I can reassure you I’m not seeing this as a good-enough fix for long words, far from it.
We actually have planned a round of Research and Development to see if the situation is any better than the last time we tried so I’ll keep participants updated here.
maerlin commentedon Aug 22, 2026
Adding a measurement from a reading system that hit this, in case the pagination side is useful for the planned R&D round.
We paginate with multicol in a
WKWebView, one column of100vwby100vh. The part that surprised us was not that the box overflows, but that the overflow does not extend the scroll extent.document.documentElement.scrollWidthstays atexactly
innerWidthin every failing case, the same value it reports when nothing overflows at all.A reading system deriving its page count from the scroll extent, in the shape
(scrollWidth + colGap) / (innerWidth + colGap), therefore never produces a page covering the overflowing content. So it is not only that the text is clipped or bleeds into the next column: there is no page the reader can turn to that would reveal it, and the reading system reports a book shorter than its own content.Measured at 320x480 CSS px, 280px of usable column, the same 120-character unbroken run inside each shape:
<p><pre><td>display: inline-blocka { white-space: nowrap }The paragraph rows pass because
word-wrap: break-wordatReadiumCSS-before.css:486breaks against the line box. The failing rows are decided by min-content intrinsic sizing instead, whichbreak-wordexplicitly does not affect per CSS Text 3, and whichmax-widthat:523cannot reduce below.overflow-wrap: anywhereis the value that does reduce min-content sizing, if that is worth including in the round.A public reproducer, since the earlier reports here could not share files: Project Gutenberg ebook 20871, Human Foods and Their Nutritive Value,
epub3.imagesedition. It has 43 tables, and in a 280px column two of its documents carry tables of 335, 330, 417, 401, 450 and 333 CSS px. Measure withoffsetWidth: inside multicol,getBoundingClientRect()returns the union of an element's fragments across columns, so a merely tall table reports an enormous width.On the table half of this we took the advice above and scale a wide table to fit one page, with a tap opening a zoomable full size view. That works well. It is the long links and inline-block boxes in running text where a reading system has less to work with.
docs: record why the ePub reader disables readium's overflow handling