HTML opposite of non-breaking space

后端 未结 5 1433
[愿得一人]
[愿得一人] 2020-12-30 19:29

In my HTML I have a very long word and I\'m trying to force a specific break point only when there isn\'t enough room. What I need is a sort of conditional-breaking placehol

5条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-30 20:03

    I'll post another alternative, as that's what I actually was looking for the first time I found this question.

    You should use a Soft hyphen instead of Zero-width space.

    From Soft hyphen:

    soft hyphen or syllable hyphen, abbreviated SHY, is a code point reserved in some coded character sets for the purpose of breaking words across lines by inserting visible hyphens.

    Also, to compare it with "Zero-width space", from Soft hyphen:

    It serves as an invisible marker used to specify a place in text where a hyphenated break is allowed without forcing a line break in an inconvenient place if the text is re-flowed. It becomes visible only after word wrapping at the end of a line. The soft hyphen's Unicode semantics and HTML implementation are in many ways similar to Unicode's zero-width space, with the exception that the soft hyphen will preserve the kerning of the characters on either side when not visible. The zero-width space, on the other hand, will not, as it is considered a visible character even if not rendered, thus having its own kerning metrics.

    You can also check out the wikipedia article with an example text that changes when the window resizes.

提交回复
热议问题