Search code examples
htmlcssline-breaks

Showing line breaks if text contains '13' and '10'


Webapi returns custom text string with 13 and 10 characters for line. If I show this custom text in html, I do not see line breaks (if I use <pre> tag, then line breaks are shown).

What should be modified in html or css to show linebreaks? I cannot modify webapi. I am using knockout data binding to insert values from webapi into html.

<p data-bind="text: $data.CustomTxt"></p>

Solution

  • Use css property "white-space: pre-line":

    Sequences of whitespace will collapse into a single whitespace. Text will wrap when necessary, and on line breaks