SmailQ
SmailQ

Reputation: 11

How to get rid of the additional line in <textarea> element

When display the same content in textarea element and pre element, the results will be different. textarea has one more line than pre.

<textarea>Hello</textarea>
<pre>Hello</pre>

Example: http://jsfiddle.net/45XkC/

That means, if I save the content in textarea and reload it in textarea again, it will always one more line compare to the previous version.

How can I get rid of the additional line in text area to make the display the same as pre element?

Updated: the content is not fixed, and the textarea is re-sizable. The question is equals to Why there is an additional line in textarea than pre, and is there any way to get rid of it in front-end?

Upvotes: 1

Views: 146

Answers (1)

andyb
andyb

Reputation: 43823

Adding the rows attribute like

<textarea rows="1">Hello</textarea>

will instruct the browser to render just 1 row.

Upvotes: 1

Related Questions