More than 1 row in <Input type=“textarea” />

后端 未结 4 1455
-上瘾入骨i
-上瘾入骨i 2020-12-25 09:23

I\'m having troubles getting my to have more than 1 row,

I tried adding the properties in the html, like you would do

相关标签:
4条回答
  • 2020-12-25 09:58

    Why not use the <textarea> tag?

    ​<textarea id="txtArea" rows="10" cols="70"></textarea>
    
    0 讨论(0)
  • 2020-12-25 10:04

    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.

    0 讨论(0)
  • 2020-12-25 10:05

    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.

    0 讨论(0)
  • 2020-12-25 10:14

    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.

    0 讨论(0)
提交回复
热议问题