Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use CSS font-family to set different fonts for English and Chinese fonts

2025-02-22 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article mainly explains "how to use CSS font-family to set different fonts for English and Chinese fonts". The content in the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn how to use CSS font-family to set different fonts for English and Chinese fonts.

The calling method of font-family:

The code is as follows:

Div {

Font-family:Arial,'Times New Roman','Microsoft YaHei',SimHei

Font:bold 12px/0.75em Arial,'Times New Roman','Microsoft YaHei',SimHei

}

According to the principle of font-family, if the client terminal does not know the previous font, it automatically switches to the second font, the second font to the third font, and so on. If none of them can be recognized, the default font is called.

According to the font call principle of font-family, we can call different fonts for English, Chinese and other fonts to render.

Such as: Arial,'Times New Roman' these two fonts do not know Chinese, only know English, so, these two fonts can only render English numbers and some special symbols, and the Chinese page will automatically call the third font Microsoft YaHei (PS: if there is such a font).

Therefore, when defining the font, write the English font in front and the Chinese font at the end. In this way, the system will automatically use fonts for words in order, and if the current font does not support text, automatically switch to the next font in the list

After testing, the font-family attribute is supported by IE9, IE9 compatibility mode (compatible with IE8), the latest version of Chrome browser (34.0) and the latest version of Firefox browser (29.0).

However, some versions of IE browsers (IE7, IE8) fail to meet the requirements of this font-family property and expose some strange bug. If you use a Chinese font (such as Microsoft Yahei) in these versions of the browser, you need to put the Chinese font in the first place in the font-family attribute, but it will cause the English font to be rendered using this Chinese font. That is, these browsers (IE7, IE8) do not support the use of different fonts for English and Chinese fonts in the font-family attribute.

Thank you for your reading, the above is the content of "how to use CSS font-family to set different fonts for English and Chinese fonts". After the study of this article, I believe you have a deeper understanding of how to use CSS font-family to set different fonts for English and Chinese fonts. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report