I want to make newline (CR and LF) characters visible in a textarea field of an HTML form, as you can do in some text editors and IDEs. The user needs to be able to edit the text to insert newlines as well (i.e. create paragraph breaks), which should also show dynamically. Is there a way to do this?
TIA....
Steve
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.
To add a line break to your HTML code, you use the <br> tag. The <br> tag does not have an end tag. You can also add additional lines between paragraphs by using the <br> tags.
Talking specifically about textareas in web forms, for all textareas, on all platforms, \r\n will work.
<textarea> is a replaced element — it has intrinsic dimensions, like a raster image. By default, its display value is inline-block .
The only way to do this is to print out your own marker characters before/after each line break, using javascript.
The character reference for the pilcrow (¶) character is ¶
.
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