To achieve the desired effect, remember to include unicode-bidi:isolate;
reference
<p style="width: 100%; direction: rtl; text-align: right;">
مهدی
<em style="direction: ltr;unicode-bidi:isolate; text-align: left;">aslami @</em>
خاوری
</p>
Furthermore, it is advisable to use the dir
attribute rather than direction
, as specified.
It is recommended for HTML authors to rely on the HTML dir attribute and <bdo>
element in order to ensure accurate bidirectional layout even when CSS styling is disabled. Avoid using direction
within HTML documents.
Note that there exists a subtle distinction between dir
and direction
.
Regarding direction:
ltr
This property establishes inline base direction (bidi directionality) from left-to-right within the line. reference
For dir:
The ltr keyword corresponds to the ltr state
Indicates explicit directional isolation for left-to-right text content within the element. reference
Therefore, utilizing dir=ltr
equals
direction: ltr;unicode-bidi:isolate;
rather than solely
direction: ltr;
Refer to the response provided by @Ori Drori
Consider employing the bdi
tag for similar outcomes:
<p style="width: 100%; direction: rtl; text-align: right;">
مهدی
<bdi><em style="direction: ltr; text-align: left;">aslami @</em></bdi>
خاوری
</p>
The bdi element isolates text from its surroundings to facilitate proper bidirectional text formatting reference