Skip to content

Conversation

@NadavTasher
Copy link

Purpose

Anchors with very long unbreakable links cause pages to be horizontally scrollable on mobile.
Fix this by allowing anchors to break anywhere.

This was observed on the following page:
https://docs.kernel.org/filesystems/ramfs-rootfs-initramfs.html#why-cpio-rather-than-tar

Screenshots

Without the proposed changes:
image

With the proposed changes:
image

NadavTasher added a commit to NadavTasher/sphinx that referenced this pull request Oct 25, 2025
@mgeier
Copy link
Contributor

mgeier commented Oct 26, 2025

I've used this before:

    overflow-wrap: break-word;

Can anyone tell which one is better in this case?

@NadavTasher
Copy link
Author

From https://stackoverflow.com/questions/17259916/difference-between-overflow-wrap-and-word-break, it seems as though word-break is actually deprecated. I'll update my PR to use overflow-wrap.

@mgeier
Copy link
Contributor

mgeier commented Oct 27, 2025

it seems as though word-break is actually deprecated.

I'm not an expert, but AFAIU your SO link (and https://developer.mozilla.org/en-US/docs/Web/CSS/word-break), only word-break: break-word; is deprecated but word-break: break-all; should be fine.

Anchors with very long unbreakable links cause pages to be
horizontally scrollable on mobile.

Fix this by allowing anchors to break words.
@NadavTasher NadavTasher force-pushed the feature/break-words-in-anchors branch from b5a8820 to eec9eb1 Compare October 27, 2025 23:39
@NadavTasher NadavTasher changed the title Allow anchors to word-break anywhere Allow anchors to wrap anywhere Oct 27, 2025
@NadavTasher
Copy link
Author

I'm not an expert, but AFAIU your SO link (and https://developer.mozilla.org/en-US/docs/Web/CSS/word-break), only word-break: break-word; is deprecated but word-break: break-all; should be fine.

I changed it to overflow-wrap, as that seems to be the go-to in other places. I tested it and it works exactly the same.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants