Home > Article > Web Front-end > How to change font in css3
In CSS, you can use the "font-family" attribute to change the font. The function of this attribute is to specify the font of the element. You only need to add the "font-family:"font name";" style to the element. .
The operating environment of this tutorial: Windows 7 system, CSS3&&HTML5 version, Dell G3 computer.
How to change the font in css3
You can use the font-family property to change the font in css.
font-family Specifies the font family of the element.
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.
There are two types of font family names:
Specified series name: the name of a specific font, such as: "times", "courier", "arial". Common font family names: for example: "serif", "sans-serif", "cursive", "fantasy", "monospace".
Let’s take a look at the specific operation of this attribute through an example. The example is as follows:
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="ie=edge"> <title>Document</title> <style> .one{ font-family:"楷体"; } </style> </head> <body> <div class="one">怎么样改字体样式</div> </body> </html>
Output result:
Add the "font-family:"宋体";" style to the element and output the result:
Add the "font-family:"黑体";" style to the element and output the result :
(Learning video sharing: css video tutorial)
The above is the detailed content of How to change font in css3. For more information, please follow other related articles on the PHP Chinese website!