77

I'm having troubles getting my <input type="textarea" /> to have more than 1 row,

I tried adding the properties in the html, like you would do with a normal <textarea></textarea> like this: <input type="textarea" rows="x" cols="x" />

I even tried to do it in CSS, but it did not work. I've searched all over the internet for a solution, but i can't seem to find a topic regarding my exact problem anywhere.

The textareas i'm experiencing this with, are on this website: Vilduhelst

When you press the "Lav dit eget dilemma" button they will appear.

I'm looking for either a HTML or CSS solution.

Jonas Pedersen
  • 911
  • 2
  • 10
  • 21
  • 1
    You need to use a – theprogrammer Oct 26 '12 at 14:53
  • 6
    tag is for Single Line TextBox, you can't make it mufti-line. For that use – Yograj Gupta Oct 26 '12 at 14:53
  • Oh gosh, is that really the problem? I asked my hostmaster who is a professional deveoper for advice on this matter, and he couldn't figure out what was wrong -.- – Jonas Pedersen Oct 26 '12 at 14:55
  • 4
    [That's not valid HTML](http://www.w3.org/TR/html401/interact/forms.html#h-17.4). It partially worked because it defaulted to `input type='text'`. – Sparky Nov 25 '12 at 06:09

4 Answers4

86

Why not use the <textarea> tag?

<textarea id="txtArea" rows="10" cols="70"></textarea>
Laurel
  • 5,965
  • 14
  • 31
  • 57
Vinod Vishwanath
  • 5,821
  • 2
  • 26
  • 40
  • 3
    I tried using the – Jonas Pedersen Oct 26 '12 at 14:53
  • I'm not sure that "textarea" is a valid value for attribute "type" of `` The textarea tag is what I've always used. What's the problem with it anyway? It renders fine here: http://jsfiddle.net/tLWrP/ – Vinod Vishwanath Oct 26 '12 at 14:56
  • You are right, i just changed it to – Jonas Pedersen Oct 26 '12 at 14:58
  • Might have been a typo in the tag name, or maybe incorrect attribute-values. Good it worked! – Vinod Vishwanath Oct 26 '12 at 15:04
  • 19
    [`input type='textarea'` is not valid HTML](http://www.w3.org/TR/html401/interact/forms.html#h-17.4). It partially worked because it simply defaulted to `input type='text'`, hence why the OP originally only saw one line. – Sparky Nov 25 '12 at 06:10
36

Although <input> ignores the rows attribute, you can take advantage of the fact that <textarea> doesn't have to be inside <form> tags, but can still be a part of a form by referencing the form's id:

<form method="get" id="testformid">
    <input type="submit" />
</form> 
<textarea form ="testformid" name="taname" id="taid" cols="35" wrap="soft"></textarea>

Of course, <textarea> now appears below "submit" button, but maybe you'll find a way to reposition it.

TheHumblePedestrian
  • 163
  • 1
  • 3
  • 12
AdamL
  • 12,421
  • 5
  • 50
  • 74
23

As said by Sparky in comments on many answers to this question, there is NOT any textarea value for the type attribute of the input tag.

On other terms, the following markup is not valid :

<input type="textarea" />

And the browser replaces it by the default :

<input type="text" />

To define a multi-lines text input, use :

<textarea></textarea>

See the textarea element documentation for more details.

Damien Flament
  • 1,465
  • 15
  • 27
6

The "input" tag doesn't support rows and cols attributes. This is why the best alternative is to use a textarea with rows and cols attributes. You can still add a "name" attribute and also there is a useful "wrap" attribute which can serve pretty well in various situations.

Kalin Varbanov
  • 363
  • 3
  • 13