How to detect '\n' in HTML. | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

How to detect '\n' in HTML.

I am working on Django. Let suppose if user input like this :- hello man Here is \n new line character in this string but when i print this string in html i got output like this hello man How i can add new line html if I got \n in string. I know about <br/> but here am working in Django and i want to print new line in html through Django.

1st Oct 2019, 4:44 PM
Maninder $ingh
Maninder $ingh - avatar
2 Answers
+ 2
I solve it using <pre>{{value}}</pre>
4th Oct 2019, 5:06 AM
Maninder $ingh
Maninder $ingh - avatar
0
{{value|linebreaks}}
4th Oct 2019, 4:34 AM
Rachmad Rezki Anditirta
Rachmad Rezki Anditirta - avatar