In a very simple HTML form I've created, I've asked the user to provide additional details and have coded this section as:
<textarea rows="1" cols="50" wrap="physical" name="comments"> </textarea>
Any idea why the cursor starts off at the middle of this box? Well, it's not directly at the middle, but it's definitely not at the start (top left) corner of the box. I see a lot of solutions here and they all require Javascript to correct this. Is there a way to do this with just html?
To set the cursor at the end of a textarea: Use the setSelectionRange() method to set the current text selection position to the end of the textarea. Call the focus() method on the textarea element. The focus method will move the cursor to the end of the element's value.
Press f12 in the browser and check the element.
Specific AttributesSpecifies the width of the textarea based on the number of visible character widths. Specifies one or more forms. Specifies the maximum number of characters in textarea. Assigns a name to the input control.
What happens when you change it to:
<textarea rows="1" cols="50" wrap="physical" name="comments"></textarea>
I think it's not starting at the beginning because you've got whitespace inside the tag.
The reason that this happens is because you have white space in between the <textarea>
tag. Try this
<textarea rows="1" cols="50" wrap="physical" name="comments"></textarea>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With