Reputation: 10589
I have localization strings with line breaks:
label.example=Text\nwith\nline\nbreaks
And i set the text using thymeleaf:
th:text="#{label.example}"
But the text is printed like:
Text with line breaks
But i want the text to appear like
Text
with
line
breaks
Why are my \n
all deleted and not rendered into line breaks? How can i keep my line breaks? It is really important.
Upvotes: 0
Views: 1117
Reputation: 691695
Because HTML considers a sequence of white space characters, including line breaks, as a single white space. Unless you tell it to preserve line breaks using CSS.
See the white-space
property
Upvotes: 3