Skip to content

Add word/line break option <wbr /> #55565

Open

Description

@hanneslsm

What problem does this address?

Some words are too long, so they will break on mobile (even with fluid typography). Unfortunately, the word break can be incorrect.
With the wbr Tag it's possible to control where the word will break. With &shy; a hyphen will be added.

Desktop (no issues) Mobile (Wrong word/line break)
Image Image
The correct word break in this word would be "Verpackungs- lösungen"
Image

What is your proposed solution?

Adding a option for line break or word break
Not sure if "(invisible)" is the best wording.
image

This is very important for making Gutenberg more attractive to non-english speaker.

Activity

  1. changed the title [-]Add line break controls `<wbr />`[/-] [+]Add line break option `<wbr />`[/+] on Oct 24, 2023
  2. added
    [Type] Enhancement
    [Block] Heading
    [Block] Paragraph
    [Feature] Typography
    on Oct 24, 2023
  3. masteradhoc commented on Oct 25, 2023

    @masteradhoc
    Contributor

    +1 from me. We get through this also a lot and would appreciate a solution :)

  4. hanneslsm commented on Oct 28, 2023

    @hanneslsm
    Author

    For everyone reading this how to break words manually until this feature exist:

    1. Go to the Code editor and search for the word
    2. Add either &shy; (word break with hyphen) or <wbr /> (without)
  5. changed the title [-]Add line break option `<wbr />`[/-] [+]Add word/line break option `<wbr />`[/+] on Oct 28, 2023
  6. added
    [Status] In Progress
    on Sep 5, 2025
  7. Mamaduka commented on Sep 7, 2025

    @Mamaduka
    Member

    I wonder if using a global setting like #55190 better resolves this. Adding these formats to each header looks like tedious work, IMO.

    Question: Similar text styling seems like a language-specific feature. I wonder if the requested custom format would be better suited for a plugin.

    cc @WordPress/gutenberg-design

  8. t-hamano commented on Sep 7, 2025

    @t-hamano
    Contributor

    It's also important to note that some languages ​​don't use soft hyphens at all.

    Japanese, for example, doesn't have spaces between words and doesn't use hyphens even when words are wrapped.

  9. jasmussen commented on Sep 8, 2025

    @jasmussen
    Contributor

    It's unclear to me that text-wrap, for the reasons Aki mentions, will work for this. I still think we want text wrap, to be clear, but not sure it's a bulletproof solution.

    So the question is first whether this is plugin territory or of core importance: I have no strong opinion there so happy to hear some consensus from the group there. Secondly if it's core territory, finding an interface to add this. And there really are a few ways this can go:

    • The inline dropdown as proposed makes sense as it handles prominence, so the tricky part is what to call the item, and what item to give it. But we wouldn't want anyone to use this character instead of pressing Enter or Shift Enter to make real linebreaks. Its behavior is pretty hard to explain.
    • Speaking of, shift enter is the way to create a <br> tag—the only way. This character does seem a bit different than a single linebreak, so perhaps a shortcut (⌥ ⇧ Enter) may not be right, but still something to consider.

    The final piece is whether this character should show anything in the canvas. It's a pretty exotic character, you might add it and forget you did.

    Perhaps a contrarian proposal, so think of this more of a brainstorming aspect: what if this was a button that existed only in the code editor?

  10. hanneslsm commented on Sep 8, 2025

    @hanneslsm
    Author

    Another solution could be that we add a global setting to the typography elements, making selecting the relatively new hyphens: auto; available: https://developer.mozilla.org/en-US/docs/Web/CSS/hyphens This way, the words would break at least correctly within the word.
    The downside is that it is that not all languages are supported by every browser yet. We would need to add at least an info text.


    Regarding the manual soft hyphen:

    So the question is first whether this is plugin territory or of core importance:

    I think it's core, because it's essential for some languages (like German and others with long words). The fact that it's part of ISO 8859-1 already since 1986 underlines it's importance. The logical evolution then though would be, with also considering Phase 4 of Gutenberg already, adding a special character inserter someday.

    Perhaps a contrarian proposal, so think of this more of a brainstorming aspect: what if this was a button that existed only in the code editor?

    I like this thinking! The code editor is currently much underutilized anyway.
    Content Mode, Freeflow mode and Coding mode (with syntax highlighting, inserting special characters, [maybe even with AI autocomplete] et cetera). There's potential. Sounds like a lot of work though 😄

    The final piece is whether this character should show anything in the canvas. It's a pretty exotic character, you might add it and forget you did.

    The first that comes to mind is that the soft hyphen character will be displayed as an overlay like in InDesign.


    Another thing to consider when implementing the soft hyphen feature are anchor links. They links should break, but the &shy; shouldn't be added to the link.

  11. BugReportOnWeb commented on Sep 9, 2025

    @BugReportOnWeb
    Contributor

    The final piece is whether this character should show anything in the canvas. It's a pretty exotic character, you might add it and forget you did.

    That's one issue I ran into while working on this. The word break only happens on smaller screens, which means it inserts invisible content. Because of this, it’s hard to toggle it off once added, and the only way to remove it is by undoing the action, which can easily get lost in the undo history if many other changes are made.

    While users can still check the code editor to find and remove it, that makes the removal process much less intuitive.

  12. t-hamano commented on Sep 9, 2025

    @t-hamano
    Contributor

    Note: there is also an issue about proposing to add the word-break option: #11956

  13. hanneslsm commented on Sep 9, 2025

    @hanneslsm
    Author

    The word break only happens on smaller screens, which means it inserts invisible content.

    To that specific statement: not necessarily only on smaller screens, also often in titles. Example: The privacy policy on one of my clients website https://www.bittner-krull.de/datenschutz/ where I had to manually add the &shy;

    Image
  14. masteradhoc commented on Sep 9, 2025

    @masteradhoc
    Contributor

    What @hanneslsm writes here is quite a well known limitation. we have to use this by default for h1,h2,h3 headings and sometimes for p. The Quickedit option works as long as no client saves the page but a solution like discussed here would be amazing to get!

  15. hanneslsm commented on Sep 16, 2025

    @hanneslsm
    Author

    I just saw another example today on WordPress.org of why this is needed.
    I'm adding a 'needs design' label. If anyone has ideas for how to visualise invisible characters, suggestions are very welcome!

    Image

  16. added
    Needs Design
    on Sep 16, 2025
  17. jasmussen commented on Sep 18, 2025

    @jasmussen
    Contributor

    I just saw another example today on WordPress.org of why this is needed.

    That's a good flag, but I think that's arguably a reason for fluid typography so the font size isn't so big that it wraps.

  18. senicar commented on Sep 25, 2025

    @senicar

    I just saw another example today on WordPress.org of why this is needed.

    That's a good flag, but I think that's arguably a reason for fluid typography so the font size isn't so big that it wraps.

    There is always a German word that you just cannot make it "fluid" and simply requires a hyphenated line break. 😃

  19. karmatosed commented on Sep 30, 2025

    @karmatosed
    Member

    I am not sure this needs design, so let's for now have it move back to feedback.

  20. added
    Needs Design Feedback
    and removed
    Needs Design
    on Sep 30, 2025
  21. jasmussen commented on Aug 25, 2026

    @jasmussen
    Contributor

    I just closed a related issue in #31401 (comment), I'm tempted to close this one for the same reason: it's good plugin territory but it's unclear that it should be directly supported in the core product. Also note, there's a PR in #74040 that makes invisible characters visible, worth looking at as it's related.

    However, there's a PR in process to address this in #71521. If folks subscribed reviewed that PR, we could possibly unblock it and get some momentum. What do you think?

  22. removed
    Needs Design Feedback
    on Aug 25, 2026
  23. dmsnell commented on Aug 25, 2026

    @dmsnell
    Member

    I just saw another example today on WordPress.org of why this is needed.

    Curious how <wbr> would help here @hanneslsm — it seems like there’s no objective break opportunity in the word, unless you are proposing that the break should fall at Guten<wbr>berg?


    Just a note for all: the WBR element is a void element in HTML, which cannot contain content. Therefore it’s preferable to leave of the mistaken “self-closing flag” which is ignored by the HTML parser. That means the canonical rendering is <wbr> and not <wbr/> or <wbr />.

    Just a fun fact: this predates XML which created the self-closing flag as syntax-minimization for the SGML null end-tag concept by updating the SGML spec to separate the null end-tag opening from the null end-tag closing delimiters.

    In XML, <wbr /> is identical to <wbr></wbr>, which is a wbr element which happens to contain no children — it’s essential a lexer macro. In HTML no such equivalent is possible because the WBR element is content-less; there is no such thing as <wbr></wbr> in HTML.

    😄

  24. hanneslsm commented on Aug 26, 2026

    @hanneslsm
    Author

    it seems like there’s no objective break opportunity in the word, unless you are proposing that the break should fall at Gutenberg?

    Correct, this was my thinking.

    Interestingly, Merriam Webster displays word breaks with a dot: Gu·​ten·​berg
    https://www.merriam-webster.com/dictionary/Gutenberg
    Image

    This is similar to the idea from above, displaying invisible characters like in InDesign:

    The first that comes to mind is that the soft hyphen character will be displayed as an overlay like in InDesign.

    Alternatively, Duden (German dictionary) uses a |
    Image
    https://www.duden.de/rechtschreibung/Gutenberg

    Not sure how helpful this information is, but I think it proofs that there are different way to display such characters in the editor. And that they are needed :)

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    [Block] Heading[Block] Paragraph[Feature] Typography[Status] In Progress[Type] Enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions