Home >Web Front-end >Front-end Q&A >How to set up Microsoft Yahei with css
How to set Microsoft YaHei in css: First create an HTML sample file; then add the p tag to the body; finally add the "font-family:"Microsoft YaHei",Microsoft YaHei;" attribute to the text. Set it to Microsoft Yahei.
The operating environment of this article: Windows7 system, HTML5&&CSS3 version, Dell G3 computer.
The font-family attribute can set the font for the label. The browser will look for the font from left to right and use the first font found for display. If not found, the default font is used (the Simplified Chinese version of Windows XP is usually Song Dynasty).
css method to set Microsoft Yahei:
css code:
.selector{ font-family:"Microsoft YaHei",微软雅黑 }
Description:
Add the Chinese name "Microsoft Yahei" for compatibility opera.
Example:
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>HTML中文网</title> <style> p{ font-family:"Microsoft YaHei",微软雅黑; } </style> </head> <body> <p>这是微软雅黑字体</p> </body> </html>
Rendering:
font-family description:
font-family specifies the element Font family.
font-family can save multiple font names as a "fallback" system. If the browser doesn't support the first font, it will try the next one. That is, the value of the font-family attribute is a precedence list of font family names or/and class family names to use for an element. The browser will use the first value it recognizes.
【Recommended learning: css video tutorial】
The above is the detailed content of How to set up Microsoft Yahei with css. For more information, please follow other related articles on the PHP Chinese website!