Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is textarea filled with mysterious white spaces?

I have a simple text area in a form like this:

<textarea style="width:350px; height:80px;" cols="42" rows="5" name="sitelink">     <?php if($siteLink_val) echo $siteLink_val; ?>  </textarea> 

I keep getting extra white space in this textarea. When I tab into it my cursor is like in the middle of the textarea and not in the beginning? What is the explanation?

like image 548
Afamee Avatar asked Feb 04 '10 20:02

Afamee


People also ask

How do I get rid of extra space in textarea?

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..

What is the white space around the text?

Alternatively referred to as spacing or whitespace, white space is any section of a document that is unused or space around an object. White spaces help separate paragraphs of text, graphics, and other portions of a document, and helps a document look less crowded.

Which tag can preserve the white space in text?

Description. The HTML <pre> tag defines preformatted text preserving both whitespace and line breaks in the HTML document. This tag is also commonly referred to as the <pre> element.

What does the textarea display?

The <textarea> tag defines a multi-line text input control. The <textarea> element is often used in a form, to collect user inputs like comments or reviews. A text area can hold an unlimited number of characters, and the text renders in a fixed-width font (usually Courier).


2 Answers

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.

like image 65
Pekka Avatar answered Oct 05 '22 03:10

Pekka


Well, everything between <textarea> and </textarea> is used as the default value for your textarea box. There is some whitespace in your example there. Try to eliminate all of that.

like image 37
amarillion Avatar answered Oct 05 '22 04:10

amarillion