Hiruni Jayawardena
Hiruni Jayawardena

Reputation: 111

In my html input field, the cursor is set into the middle. How can I set my cursor to the right position?

I'm developing my form only just using HTML and CSS. I have created the input fields with the rounded border. I need to set my cursor to the beginning of the input field.

<input type="text" id="itemName" name="itemName" 
  style="border-radius: 4px; padding: 6px 236px;" 
  wrap="physical">

Upvotes: 2

Views: 3318

Answers (2)

code and pixels
code and pixels

Reputation: 674

If you want all of the text/words on your site to flow right-to-left (as in for languages not written left-to-right), then use the direction CSS property.

However if you just want to change the cursor placement in your input fields, you'll want to use the text-align property:

input {
  text-align: left;
}

If it helps I threw together a code example: https://codepen.io/code-and-pixels/pen/gJNGaL

Upvotes: 1

Codesigner
Codesigner

Reputation: 587

To set cursor to right side use "direction" rule of CSS

input{
    direction: rtl;    
}

To set offset we may use "text-indent" rule

input{
    direction: rtl; 
    text-indent: 10px; // based on your border radius and input size you may change it
}

Upvotes: 3

Related Questions