html (+css): denoting a preferred place for a line break

前端 未结 9 1657
南旧
南旧 2020-11-28 03:08

Let\'s say I have this text that I want to display in an HTML table cell:

Honey Nut Cheerios, Wheat Chex, Grape-Nuts, Rice Krispies, Some random cereal with          


        
9条回答
  •  感动是毒
    2020-11-28 03:48

    The answer is no (You cannot alter the line breaking algorithm used).

    But there are some workarounds (best one is the accepted answer)

    You can go near with the non-breaking-space   but only between words that go together (what you have in spans, but not after the comma ), or you can use the white-space:nowrap as @Marcel mentioned.

    Both solutions do the same thing, and both will not break a group of words if it does not fit on its own.

提交回复
热议问题