2

Is there a way to preserve line breaks from user input. At the moment I am just getting the user input sending it to mongoDb and returning that text. However if my input is : "new line", my output would be "new line". Can anyone suggest a fix?

1

2 Answers 2

4

Use css white-space for styling it.

.foo {
  white-space: pre-line;
}
Sign up to request clarification or add additional context in comments.

Comments

0

a small addition to @FELIXMOSH's correct answer: also use word-wrap because white-space property can cause overflowing sometimes. And apply this css to the element that will host the mongodb data.

anyClass {
  white-space: pre-wrap;
  word-wrap: break-word; 
}

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.