Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cursor in the middle of a textarea box?

Tags:

html

css

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?

like image 481
Ray Avatar asked Jan 30 '12 21:01

Ray


People also ask

How do I change the cursor position in textarea?

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.

How do I change cursor position to the top left edge of input?

Press f12 in the browser and check the element.

What are the two attributes of textarea tag?

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.


2 Answers

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.

like image 92
nachito Avatar answered Sep 23 '22 20:09

nachito


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> 
like image 40
Rokin Maharjan Avatar answered Sep 21 '22 20:09

Rokin Maharjan