How to wrap long lines without spaces in HTML?

前端 未结 14 1869
旧巷少年郎
旧巷少年郎 2020-12-01 03:28

If a user types in a long line without any spaces or white space, it will break formating by going wider than the current element. Something like:

HA

14条回答
  •  攒了一身酷
    2020-12-01 03:59

    There is no "perfect" HTML/CSS solution.

    The solutions either hide the overflow (ie scrolling or just hidden) or expand to fit. There is no magic.

    Q: How can you fit a 100cm wide object into a space only 99cm wide?

    A: You can't.

    You can read break-word

    EDIT

    Please check out this solution How to apply a line wrap/continuation style and code formatting with css

    or

    How to prevent long words from breaking my div?

提交回复
热议问题