Textarea Add space to top of text?

I had a strange problem: I have php inserting text in <textarea>, and <textarea>adds one space to the beginning of my text.

I created an example page to display the problem ... here is the code behind the page.

<textarea style="width:600px;height:100px;"><?php get_film_info('main description'); ?></textarea>
<br>
<textarea id="mainDescription style="width:600px;height:100px;">Text just typed in</textarea>
<br>
<?php get_film_info('main description'); ?>

You can see that without a tag, the <textarea>text does not include indentation. My database also does not reflect indentation as well as php output outside <textarea>...

Is it possible to understand what can happen?

sample page

Edit: Everything is fine with you, of course, I did not check the source code of the output file. It turns out that when I added data (via ajax), I sent my data, for example var data = '&main_description= ' + mainDescription. Note the space between "=" and "+".

, .

+3
5

, . , get_film_info() .

+1

:

trim(get_film_info('main description'));
+4

! , "get_film_info" , !

+2

get_form_info() . " " ( , ). , get_film_inflo().

0
source

Space exists. Outside the text field, the browser does not interpret them, because \ n means nothing (it is interpreted only in the source code) only in plain text form. However, \ n inside a text field is a line break and is interpreted as such.

To solve the problem, you can always crop it to output.

0
source

Source: https://habr.com/ru/post/1737209/


All Articles