JAVASCRIPT - HOW TO Force Firefox Textarea to Line Break - Javascript Source Code

JAVASCRIPT - Normal Line Break or not Working for Textareas in Mozilla Firefox? How to Get Firefox to Recognize and Apply Line Breaks or Carriage Returns Properly.

Home Short:

In Javascript, you enter line by line text in an html textarea with code similar to the following: document.getElementById('tarea').value += 'text to enter\n';.

With the above code the \n normally causes a line break so whatever is entered in the textarea next is output on a new/next line. Most devices recognize and honor this new line character code but many if not most versions of Firefox do not.

Solving this textarea non line break issue with Firefox web browser is actually not a Javascript issue but a css issue.

To force the line break in a textarea in Firefox simply add the following to the textarea markup: style="word-break:break-all;-ms-word-break:break-all;". Below is an example of the html code for a textarea with this css markup code added.

This css code to force Firefox textareas to line break when they are suppose not only fixes this issue with Firefox, but most any browsers that have been known to cause this line break issue.

S
H
A
R
E