HTML Direction rtl issue

2019-02-22 09:31发布

I am working on a Multilanguage website , where in a table one of the td needs to be arabic stuff - which we know need to start from right. I tried it in many ways but couldnt crack it . Would be really appreciated if some one could help me :( .

Here in this text , the content should start from right..

 <TD><div dir="rtl">
  خیز ای عشق مجرد مهر را از سر بگیر<br/>
مردم و خالی شدم ز اقرار و از انکار خود
      </div></TD>

5条回答
Explosion°爆炸
2楼-- · 2019-02-22 10:01

Set the dir=rtl attribute on the td element: <td dir=rtl>...</td>. The HTML attribute should be used instead of the corresponding CSS property, since the basic writing direction is not just a presentational suggestion but something that depends on the content.

You could also set it on an inner element, e.g. <td><div dir=rtl>...</div></td>. But e.g. code like <TD><span dir="rtl"><p>... won’t work, sice the <p> closes the open span element, so the span element has no content and its attributes have no effect.

Added info: Also make sure that no CSS or HTML setting is overriding the desired effect. For example, align=left on the tr element would set the alignment of all cells to left alignment, and the dir=rtl attribute won’t “win” it on its own. (If there is such an attribute and you can’t remove it, set the cell alignment explicitly, using align=right in HTML.)

查看更多
做自己的国王
3楼-- · 2019-02-22 10:13

the solution is to put the dir="rtl" (direction:rtl) on the table tag not on td tag. it works fine for me

查看更多
放我归山
4楼-- · 2019-02-22 10:14

I suppose you missing alignment option.

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 HTML align="right" or CSS text-align:right which is used to control visual display alignment.

查看更多
等我变得足够好
5楼-- · 2019-02-22 10:18

Both of these are OK:

<style type="text/css">
        body { direction:rtl; }
</style>

or this:

 <body dir="rtl">

or for HTML5: (but this doesn't work always)

 <body dir="auto">
查看更多
forever°为你锁心
6楼-- · 2019-02-22 10:26

The code is:

<html dir="rtl">

Updated answer using CSS:

Try this:

<span style="direction:rtl;">Arabic Text</span>
查看更多
登录 后发表回答