I have a simple text area in a form like this:
Look closely at your code. In it, there are already three line breaks, and a ton of white space before </textarea>
. Remove those first so that there are no line breaks in between the tags any more. It might already do the trick.
Open (and close!) your PHP tags right after, and before, your textarea
tags:
<textarea style="width:350px; height:80px;" cols="42" rows="5" name="sitelink"><?php
if($siteLink_val) echo $siteLink_val;
?></textarea>
If you still like to use indentation, do it after opening the <?php
tag, like so:
<textarea style="width:350px; height:80px;" cols="42" rows="5" name="sitelink"><?php // <--- newline
if($siteLink_val) echo $siteLink_val; // <--- indented, newline
?></textarea>
In short:
<textarea>
should be closed immediately on the same line where it started.
General Practice: this will add-up line-breaks and spaces used for indentation in the code.
<textarea id="sitelink" name="sitelink">
</textarea>
Correct Practice
<textarea id="sitelink" name="sitelink"></textarea>
Just define your and your close tag in same line.
<textarea class="form-control"
id="newText"
rows="6"
placeholder="Your placeholder here..."
required
name="newText"></textarea>
One solution that has worked for me is adding the style white-space: normal;
to the textarea because at times it is not feasible to eliminate all the whitespace (for example when you want your code to abide to your coding guidelines which requires adding tabs, whitespaces and line breaks)
Please note that the default for textarea, at least in chrome is:
white-space: pre-wrap;