# Reversing text for arabic

**URL:** <https://forum.kirupa.com/t/reversing-text-for-arabic/261149>\
**Category:** web dev\
**Created:** [May 23, 2008, 3:06pm UTC](https://forum.kirupa.com/t/reversing-text-for-arabic/261149 "2008-05-23T15:06:42Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![opel](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/opel/32/199_2.png) [@opel](https://forum.kirupa.com/u/opel)\
**Post date:** [May 23, 2008, 3:06pm UTC](https://forum.kirupa.com/t/reversing-text-for-arabic/261149/1 "2008-05-23T15:06:42Z")

</div>

I am working on a website for a client where they have had all their text translated into arabic. I now have the task of styling the text so it reads correctly.

I have the text right aligned I just cannot get the text in my style sheed to reverse so that the text is legible in arabic.

I have googled everything I can think of and tried direction :rtl; and changed the doc type with no success ☹

---

<div class="post-metadata">

**Author:** ![Templarian](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/templarian/32/7152_2.png) [@Templarian](https://forum.kirupa.com/u/Templarian)\
**Post date:** [May 23, 2008, 5:25pm UTC](https://forum.kirupa.com/t/reversing-text-for-arabic/261149/2 "2008-05-23T17:25:39Z")

</div>

CSS:

```auto
direction: rtl; unicode-bidi: bidi-override;

```

[ot]The JS way

```auto
<div id="content">This will become reversed!</div>
<script type="text/javascript">
function strrev(str) {
   if (!str) return '';
   var revstr='';
   for (i = str.length-1; i>=0; i--)
       revstr+=str.charAt(i)
   return revstr;
}
document.getElementById('content').innerHTML = strrev(document.getElementById('content').innerHTML);
</script>

```

Downside being in either the JS or PHP way you will reverse your tags if you have any bolding or any other type of formating.[/ot]

---

<div class="post-metadata">

**Author:** ![fasterthanlight](https://avatars.discourse-cdn.com/v4/letter/f/ecc23a/32.png) [@fasterthanlight](https://forum.kirupa.com/u/fasterthanlight)\
**Post date:** [May 23, 2008, 5:36pm UTC](https://forum.kirupa.com/t/reversing-text-for-arabic/261149/3 "2008-05-23T17:36:14Z")

</div>

unless your fancy JS script accounted for that…

if (strong) { NO REVERSE }

lol
