Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
195 views
in Technique[技术] by (71.8m points)

html - How to have a line break in input type = "text"

enter image description here

Is there any way I can make the Description box become into two lines box instead of a single line block?

<label>Description</label>
<input type="text" name="description" size="50" required class="input" placeholder="Enter the description of the product">           
question from:https://stackoverflow.com/questions/65863343/how-to-have-a-line-break-in-input-type-text

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

unfortunately HTML doesn't allow you to make an input multi-line but you can use a textarea instead. (See the code snippet below) I've set "rows" to 2 since you mentioned you wanted it to take 2 lines instead of just 1, you can change that to be whatever number of lines you want.

<form action="/form/submit" method="post">
   <label for="text">Description:</label>
   <br>
   <textarea id="text" name="text" rows="2" cols="50"></textarea>
   <br/>
   <input type="submit" value="Submit">
</form>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...