In a right-to-left language (for example, Arabic and Hebrew), the bracket is canceled

Now I have a line like (in ltr)

Hebrew text (3)

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

מחיר אחד (3)

(I actually entered the Hebrew symbol (3), now it has automatically become the same as above ↑)

is there any way to do this like

(3) Hebrew text

(using html or css)

+8
source share
4 answers

You do not need to wrap the text in square brackets in a separate space.

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

Same:

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

NB: If you set the dir="rtl" attribute in an element, then even the RLM command character is not needed.

Same:

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

CODEPEN (jsFiddle down by me)

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

+10
source

(updated: thanks to clarify your comment)

this is a slightly less invasive solution ( jsFiddle result ):

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

It seems that the last parentheses are treated as punctuation and, therefore, are treated differently. This article gave me some clarity:

... Note that unlike align = "right", punctuation also moves ... See an Example RTL Document

In the sample document, the same movement of the last parentheses also occurs in the subtitle "Bidirectional Override (BDO)".

* checked jsfiddle solution in latest chrome / ff / safari / ie

+5
source

one solution is to add **&#x200e;** after the bracket

thanks to @freeworlder for the solution, the brackets don't display correctly for the display style from right to left

even you can use other char, follow this link http://www.codetable.net/hex/200e

0
source

Chrome version 75.0.3770.100 (official build) (64-bit) on Windows 10 still gets the brackets back for <p dir="rtl"> . The solution for me was to use <span dir="rtl"> .

0
source

Source: https://habr.com/ru/post/952266/


All Articles