Html – In right-to-left language(like Arabic and Hebrew),bracket reversed

csshtmlright-to-left

Now I have a string like (in ltr)

Hebrew text(3)

and when I use dir="rtl" or direction:rtl to redirect the string it actually goes:

מחיר אחד(3)

(actually i entered Hebrew charactor(3) just now it automaticlly became like above↑)

is there any way to make it like

(3)Hebrew text

(using html or css)

Best Answer

You don't need to wrap the bracketed text in a separate span.

Rather, to fix this problem add a RLM control character (‏) after the closing bracket. The RLM character acts as another Hebrew/Arabic character and so the bracket ( which is a weak character) changes its direction and moves to its correct place.

Like so:

<div>מחיר אחד(3)&rlm;</div>

NB: If you set the attribute dir="rtl" on the element - then even the RLM control character is unnecessary.

Like so:

<div dir="rtl">מחיר אחד(3)</div>

CODEPEN (jsFiddle down by me)

This microsoft doc explains the RLM control character along with other similar control characters.