Home > Web Front-end > Front-end Q&A > How to set fontfamily in css

How to set fontfamily in css

藏色散人
Release: 2023-01-05 16:11:05
Original
3828 people have browsed it

How to set fontfamily in css: first create an HTML sample file; then define some text through the p tag in the body; finally pass "p.serif{font-family:"Times New Roman",Georgia,Serif }" Just set the font.

How to set fontfamily in css

The operating environment of this article: Windows7 system, HTML5&&CSS3 version, Dell G3 computer.

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". Typical font family names: For example: "serif", "sans-serif", "cursive", "fantasy", "monospace"

Tip: Separate each value with a comma and always provide a family name as a last resort.

Note: The use of a specific font family (Geneva) depends entirely on whether the font family is available on the user's machine; this attribute does not indicate any font download. Therefore, it is highly recommended to use a common font family name as a fallback.

How to set fontfamily in css Code example:

<html>
<head>
<style type="text/css">
p.serif{font-family:"Times New Roman",Georgia,Serif}
p.sansserif{font-family:Arial,Verdana,Sans-serif}
</style>
</head>

<body>
<h1>CSS font-family</h1>
<p class="serif">This is a paragraph, shown in the Times New Roman font.</p>
<p class="sansserif">This is a paragraph, shown in the Arial font.</p>

</body>
</html>
Copy after login

Effect:

How to set fontfamily in css

##[Recommended learning:

css video tutorial

The above is the detailed content of How to set fontfamily in 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