Sergi Sergi - 2 months ago 6
HTML Question

Fixed height text input field, text on top

I have a text input field with a fixed height, I want the box to look big because of the considerable amount of text that has to be typed in it. The problem is, when the height is set and the user clicks in the box, the text starts right at the center of the box, I would like the text to start on top. My code:

HTML

<html>
</body>

<div>
<form>

<input type="text" id="mainText" value="Your text">
<button> Submit Text </button>

</form>

</div>

</body>
</html>


CSS

#mainText {width:400px; height:300px;}

Answer

Try using an input type called textarea. It's better for large amounts of text. See https://developer.mozilla.org/en-US/docs/Web/HTML/Element/textarea

Example usage:

<textarea id="mainText" name="mainText">Your text</textarea>