Search code examples
csshtmlalignmentright-to-left

Aligning contents of a div right while keeping text direction in input fields going ltr


I am trying to aligning contents of a div to right edge, but I'm getting 'direction: rtl' effect (right to left), without specifying the width of the div? while keeping text direction in input fields going ltr (left to right). Is it possible?

Applying direction: right to div almost acheives effect, except text fields inputs also become rtl. (I guess align: right also works, but is depreciated)


Solution

  • <div style="direction: rtl;">
        Text is right-aligned
        <input type="text" value="Some value" style="direction: ltr;" />
    </div>