How to save user-entered line breaks from a TextArea to a database?

anonymous·2023년 2월 22일

1 TextArea HTML element is preserving the white space in the database.
The problem appears when trying to display the \n on the web browser, which will fail.

To display \n in the web browser use :

<p style="white-space: pre-line">multi-line text</p>

2 Just put the output text between

 tags, that will preserve the line breaks.

Reference

https://stackoverflow.com/questions/498461/how-to-save-user-entered-line-breaks-from-a-textarea-to-a-database

profile
기술블로거입니다

0개의 댓글