Stylize text to use different fonts for different languages?

前端 未结 5 1078
一整个雨季
一整个雨季 2021-01-19 10:44

Is there a way to stylize text on an HTML page such that it automatically uses a different font for different languages? My website uses both English and Arabic. I\'d like t

5条回答
  •  暗喜
    暗喜 (楼主)
    2021-01-19 11:25

    If you are using UTF-8 encoding, the contents should come out in the correct character encoding, but will still be using the same font.

    You'd need to assign a CSS class to the elements containing the Arabic. CSS cannot detect this by itself.

    You could do this using JavaScript to perform this task at load-time be inspecting elements and determining the character range used.

提交回复
热议问题