How to force a piece of text to be 'direction ltr' inside a 'direction rtl' paragraph

后端 未结 3 1199
-上瘾入骨i
-上瘾入骨i 2021-02-02 09:47

So, phone numbers are always ltr (left to right).

Working on a multilingual website I need to insert a phone number (with a \'+\' prefix and numbers separated by \'-\')

相关标签:
3条回答
  • 2021-02-02 10:26

    You can use a unicode directionality marker character just before the + sign to give the algorithm the hint it needs.

    These are:

    LTR: 0x200E
    RTL: 0x200F
    

    So:

    <p id="text">Please call to <span id="phone">&#x200F;+44-123-321</span> for some help</p>

    See this SO answer for more details.

    0 讨论(0)
  • 2021-02-02 10:32

    Another option could be to use dir='ltr' attribute, in your inline element:

    <p id="text">Please call to <span dir='ltr'>+44-123-321</span> for some help</p>
    

    Please note that including &#x200E; in your HTML is as bad as using dir='ltr' attribute.

    0 讨论(0)
  • 2021-02-02 10:33

    Try adding #phone {direction:ltr; display:inline-block}

    0 讨论(0)
提交回复
热议问题