Answers for "new line not working in inner html"

0

html text content new line

//setting this css style solving problem with new line in textContent
h1.setAttribute('style', 'white-space: pre;');

//add \r\n in text everywhere You want for line-break (new line)
h1.textContent = "this is line one  \r\n and this is line 2";
Posted by: Guest on September-22-2020
1

Using new line(\n) in string and rendering the same in HTML

<span style="white-space: pre-line">@Model.CommentText</span>
Posted by: Guest on July-09-2021

Browse Popular Code Answers by Language