How to adjust font in css

藏色散人
Release: 2022-12-30 11:13:38
Original
16660 people have browsed it

How to adjust fonts in css: 1. Use the font-family attribute to specify the font family of the element; 2. Use the font-weight attribute to set the thickness of the text; 3. Use the color attribute to adjust the color of the text.

How to adjust font in css

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

In CSS, you can use font-family to change the font style, use the font-weight attribute to change the font thickness, and use the color attribute to change the font color; you can also change the font within the element by setting the css style of the element where the text is located. .

The following will introduce several attributes for changing fonts:

1. Font-family attribute

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".

Usual font family names: For example: "serif", "sans-serif", "cursive", "fantasy", "monospace"

2, font-weight attribute

# The ##font-weight property sets the weight of the text.

Description

This attribute is used to set the bold font used in the text of the display element. The numeric value 400 is equivalent to the keyword normal, and 700 is equivalent to bold. The font bold for each numeric value must be at least as thin as the next smallest number, and at least as thick as the next largest number.

3. Color attribute

The Color attribute specifies the color of the text.

Note: Please use a reasonable combination of background color and text color to improve the readability of the text.

Example of how to change fonts in css:

<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<title>DIV+CSS怎么样改字体样式</title>
<style>
.one{
font-family:"微软雅黑";  //把 font-family: "设置字体名称" 里的字体名称改成你需要
font-size:12px;  //字体大小
color:red;  //字体颜色
font-weight:normal; //加粗 normal默认值 bold粗体 数值100-900
}
</style>
</head>
<body>
<div class="one">DIV+CSS怎么样改字体样式</div>
</body>
</html>
Copy after login

Recommended: "

css video tutorial"

The above is the detailed content of How to adjust font 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