How can I prevent having just one hanging word on a new line in an HTML element?

前端 未结 3 1639
借酒劲吻你
借酒劲吻你 2021-02-05 04:37

I\'m building a simple webpage with some marketing content. One thing I don\'t like is that if a line of text is too long, it will wrap onto the next line, which is fine

3条回答
  •  清酒与你
    2021-02-05 05:06

    The simple solution is to use a non-breaking space between the last two words at the end of a paragraph.

     
    

    Such and such doesn't have to be difficult. Such and such product makes it easy

    This could get tedious if you have a lot of content and especially if it is business controlled. In that case you may be able to find a library or write a solution that automatically inserts the non-breaking space between the last two words of every paragraph for you.

    Try this: https://matthewlein.com/tools/widowfix

提交回复
热议问题