How to invert the side that starts the digits in an HTML input?

Asked

Viewed 403 times

2

For example in the 'Numeral formatting' part of this site https://nosir.github.io/cleave.js/

When I type, the numbers start to be written from right to left, and the default is any input is left to right.

How do I change the input to look like this when I type?

1 answer

6

Do not use direction: rtl for that. Although it produces the expected result, it hurts the semantics of HTML, since the purpose of RTL is to indicate that the content of that element is in a language that is written from right to left: it is a property of localization, not formatting.

Since you just want to format the text, use the text alignment property.

input[type=number] {
  text-align: right;
}
<input type="number">

  • Wow, I’m glad you answered that question. I didn’t know about the language relationship.

  • 1

    @Caiqueromero Site is here for this: share knowledge :D

  • I will take the hint and fix an old answer my xD

Browser other questions tagged

You are not signed in. Login or sign up in order to post.