Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HTML formatting Arabic text letters

Tags:

html

css

arabic

I want to color some letters in an Arabic text, for instance this text:

إذا ماطمحت إلى غاية

that gives me this normal text:

enter image description here

So I put some letters in tags to color them:

HTML:

إذا <b>م</b>اط<b>م</b>حت إلى <b>غ</b>اية

CSS:

b {
    color: #e74c3c;
}

and this gave me:

enter image description here

But I want it to give a normal readable Arabic text like that:

enter image description here

I tried changing font but it seems to be the same problem with all fonts so the issue is not in fonts.

like image 362
Burawi Avatar asked Feb 02 '16 10:02

Burawi


2 Answers

Try adding a zero-width joiner Unicode character before the opening span tag. You should check this in all browsers, as it is an issue that some can't cope with.

like image 170
David Glickman Avatar answered Sep 20 '22 23:09

David Glickman


I have a test here, but I find small cuts between red color letters and following letter:

إذا <b>م&zwj;</b>ا ط<b>م&zwj;</b>حت إلى <b>غ&zwj;</b>اية

https://jsfiddle.net

like image 41
Basheer Avatar answered Sep 22 '22 23:09

Basheer