Home » Html » How to remove extra space inside textarea

How to remove extra space inside textarea

Posted by: admin January 2, 2018 Leave a comment

Questions:

I have a textarea which displays some data from “history” column in my database.
For unknown reason there is nearly 1.5 line of extra space before the text. Anyone can give me some idea why does it happen?
Here is my HTML piece:

<div>
  <table>
    <tr>
      <th > History:</th>
      <td>
        <textarea style="margin-left:90px";  name="history"cols="80"label="notes"rows="4"wrap="virtual"> 
        <?php echo $my_class->history;?></textarea>
      </td> 
    </tr>
  </table>
</div>

You can see the problem here:enter image description here

Answers:

Its because your php tag is on a newline. It is reading in the whitespace from where <textarea> ends until php tag opens. Put this all on one line to fix.

Questions:
Answers:

I know its late but may help others.

use this when document indentation is required.

$('document').ready(function()
{
    $('textarea').each(function(){
            $(this).val($(this).val().trim());
        }
    );
});

Same Question : https://stackoverflow.com/a/44773825/3775083

Questions:
Answers:

Just put your php open tag right after the textarea close tag.. Dont use line break.. And close php exactly before (as you have done).. This will erase all the whitespaces..

Questions:
Answers:

Put this all on one line for fix this issue.Make your code like this.

<textarea style="margin-left:90px";name="history"cols="80"label="notes"rows="4"wrap="virtual"><?php echo $my_class->history;?></textarea>