Why doesn’t JavaScript newlines work inside HTML?

I had:

<div>Hello\nworld</div>

I added the below css to div class and it’s working now:

div {
      white-space: pre-wrap;
  }

I hope this solve your problem too.

Leave a Comment