13

In my webpage I set the locale to arabic and want to change the direction of the content display from right to left by using <html dir = "rtl">. But it is not displaying all the divisions of webpage from right to left some are getting reflected and some are not.

Is there any suggestion to change all the content display from right to left of a web page?

Raptor
  • 53,206
  • 45
  • 230
  • 366
user2871255
  • 149
  • 1
  • 1
  • 3
  • You set the rtl for the text, you need to change your floats and margins for it to work. – Patsy Issa Nov 15 '13 at 09:03
  • 2
    Also, can you post some example codes / examples? – Raptor Nov 15 '13 at 09:04
  • The attribute sets specific features such as layout direction of tables and the basic writing direction of text. It does not magically change things if you e.g. place some element to the left with CSS positioning. Please post a code example that demonstrates what you mean and specify what is the problem (expected/desired rendering vs. actual rendering). – Jukka K. Korpela Nov 15 '13 at 09:20

7 Answers7

34

This is old question, but i hope it'll help someone, If direction:rtl; didn't work then try to override bidi in your css

unicode-bidi: bidi-override !important;
direction: unset !important;
text-align:right;
Jo Data
  • 349
  • 3
  • 4
  • 4
    Thanks, The `unicode-bidi` property solved my problem – Amir Astaneh Oct 10 '19 at 16:26
  • `unicode-bidi: bidi-override !important;` will mess up your numbers it seems. 10:16:56 becomes 65:61:01 which is nonsense of course or easier 2022 will become 2202. – C.O. Nov 17 '22 at 21:08
4

The following code

body {
   direction: rtl;
}

will work like sugar.

Alex M
  • 2,756
  • 7
  • 29
  • 35
Renil Babu
  • 2,118
  • 1
  • 20
  • 29
3

HTML dir="rtl" or CSS direction:rtl is to control BiDi for the language script.

But in most cases where mixing different scripts you need to add also HTML align="right" or CSS text-align:right which is used to control visual display alignment.

user.dz
  • 962
  • 2
  • 19
  • 39
  • Is this fine? https://stackoverflow.com/questions/50597254/can-i-use-below-code-html-css-to-make-my-website-compatible-with-rtl – Krupal Patel May 30 '18 at 06:12
1

Jsut use this style:

direction: ltr; 
unicode-bidi: embed;
Ashnet
  • 404
  • 5
  • 5
0

You can use CSS instead:

* {
  direction: rtl;
}

You can use * selector: https://www.w3schools.com/cssref/sel_all.php (See 'More Examples')

Gerrit Bertier
  • 4,101
  • 2
  • 20
  • 36
Knelis
  • 6,782
  • 2
  • 34
  • 54
0

in my case it was input type text and the value was url appearing like

"/https://test.com" instead of "https://test.com/" even this didn't help

after trying for a while finally following solution worked for me

.align-right-dir-ltr {
    text-align: right;
    direction: ltr;
}

note : in my html is the dir = "rtl"

Uttam Ughareja
  • 842
  • 2
  • 12
  • 21
0

I just ran into this issue on an HTML input. This CSS solution worked in Chrome.

    .rtl {
        direction: rtl;
        unicode-bidi: bidi-override !important;
    }
Steve11235
  • 2,849
  • 1
  • 17
  • 18