How css loads external font files
This article mainly introduces "how css loads external font files". In daily operation, I believe many people have doubts about how css loads external font files. The editor consulted all kinds of materials and sorted out simple and easy-to-use methods of operation. I hope it will be helpful for you to answer the doubts of "how css loads external font files". Next, please follow the editor to study!
In css, you can load external font files using the "@ font-face" rule, syntax @ font-face {font-family: font name; src:url (external font file path); [font-weight: weight value]; [font-style: style value];} ".
The operating environment of this tutorial: windows7 system, CSS3&&HTML5 version, Dell G3 computer.
In css, you can use the "@ font-face" rule to load external text.
Font-face is a module in CSS3 that embeds user-defined Web fonts into your web page.
By using the @ font-face rule, Web designers no longer have to use any of the "web security" fonts.
In the @ font-face rule, you must first define the font name (for example, myFirstFont), and then point to the font file.
Syntax rules for @ font-face:
Font-face {font-family: font name; src: [] [, []] *; [font-weight:]; [font-style:];}
Font-family: font name: custom font name (generally set to the introduced font name), which is referenced in subsequent style rules.
Src: sets the loading path and format of fonts, separating multiple loading paths and formats by commas
Srouce: the loading path of the font, which can be absolute or relative URL.
Format: font format, mainly used for browser recognition, generally have the following types-truetype,opentype,truetype-aat,embedded-opentype,avg and so on.
The method of using external font files in css
1. First download the font and put it in the font directory
2. Use the @ font-face rule to introduce the font and give the name an appropriate name
Font-face {font-family: 'fontnameRegular'; src: url (' fontname.eot'); src: local ('fontnameRegular'), local (' fontname'), url ('fontname.woff') format (' woff'), url ('fontname.ttf') format (' truetype'), url ('fontname.svg#fontname') format (' svg');}
3. Use the font you just defined
H2 {font-family: fontnameRegular} at this point, the study on "how css loads external font files" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!