In a form I have a textarea where obviously text is entered. When the input is finished the content gets submitted to the server and is being stored in a database...
When I display the input the user made within a table, the newlines are not visible. When I inspect the source the newlines are there, but within a table the newlines do not work...
Is there any possibility of displaying the linebreaks within that table? I know, probably a really silly question but I'm not to pro when it comes to things like html and css...
Any help is really appreciated!
On Windows operating system, use Alt + Enter for a line break.
Preserve Newlines, Line Breaks, and Whitespace in HTML If you want your text to overflow the parent's boundaries, you should use pre as your CSS whitespace property. Using white-space: pre wraps still preserves newlines and spaces. Enjoy!
Press "enter" to submit and "shift+enter" to generate a new line. How to add line breaks to an HTML textarea?
Complete HTML/CSS Course 2022 To create a multi-line text input, use the HTML <textarea> tag. You can set the size of a text area using the cols and rows attributes. It is used within a form, to allow users to input text over multiple rows.
Set your css in the table cell to
white-space:pre-wrap;
\n won't be rendered as a new line in HTML. You have to use a <br/>
to achieve this effect.
Use a string replace to replace all '\n' characters to '<br/>
'
If you are using a server side language like C# you can do this
private string PutLineBreaks(string strData)
{
string strReplaced = string.Empty;
Regex r = new Regex("/\n/g");
strReplaced = r.Replace(strData, "<br/>");
return strReplaced;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With