Preserve line breaks in textarea

前端 未结 4 1903
生来不讨喜
生来不讨喜 2020-11-27 16:11

I have a form with a textarea and I want to preserve line breaks entered by the user when outputting the content.

For exemple, if I write in textarea :

4条回答
  •  悲&欢浪女
    2020-11-27 17:06

    Generally you just need to add

    • white-space: pre-line; whitespace trimmed to single whitespace or

    • white-space: pre-wrap; all whitespace preserved

    to the element's style (CSS), where you want your text rendered with line-breaks.

提交回复
热议问题