Home > Web Front-end > Front-end Q&A > How to set up Microsoft Yahei with css

How to set up Microsoft Yahei with css

藏色散人
Release: 2023-01-04 09:35:31
Original
6560 people have browsed it

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.

How to set up Microsoft Yahei with css

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",微软雅黑
}
Copy after login

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>
Copy after login

Rendering:

How to set up Microsoft Yahei with css

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!

Related labels:
css
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template