To understand how the user agent determines the thickness of the font deformation, we must first talk about keywords 100 to 900, and then we will look at how it is inherited.
font-weight allowed values normal | bold | bolder | lighter | l00 | 200 | 300 | 400 | 500 | 600 | 700 | 800 | 900
These numeric keywords are used to define and The mapping relationship of the related characteristics of the font, that is, the thickness of the font is divided into nine levels. For example, OpenType uses a nine-value numeric level. After the font has this level, these numbers are mapped directly to each level, such as 100 mapping to the lightest font distortion, and 900 corresponding to the heaviest font distortion.
In fact, there is no essential font weight convention in these numbers. CSS states that the font weight corresponding to each number must not be smaller than the font weight corresponding to the number before it.
In this way, 100, 200, 300 and 400 may all correspond to font deformations of the same thickness, while 500 and 600 may correspond to a thicker font deformation, and 700, 800 and 900 may correspond to another thicker font deformation. Bold font distortion.
This number is defined as the same as some ordinary, and 700 corresponds to bold.
Font deformation names are equivalent. 400 is equivalent to normal
Other numbers do not correspond to any
font-weight attribute keywords, but they can correspond to ordinary font deformation names. If a font variant is tagged "Normal", "Regular", "Roman", or "Book", then it is assigned 400, and any font variant tagged "Medium" is assigned 500.
However, if the font variant marked "Medium" is the only available font, then it cannot correspond to 500.
If there are fewer than nine font weights in a given font family, the user agent has more work to do. In this case, it must fill the gaps in a predefined way:
If the value 500 is not assigned, it is given the same font weight as 400.
If 300 is not allocated, it corresponds to a slightly lighter font variant than 400. If no lighter font is available, 300 corresponds to a grade just like 400. This is usually in the "Normal" and "Medium" cases. The same method is used for 100 and 200.
If 600 is not allocated, it corresponds to a slightly heavier font variant than 400. If no such font is available, 600 corresponds to a certain font variant just like 500. This method is also used on the 700, 800 and 900.
For ease of understanding, let us look at three
examples of font weight allocation. First, assume that the font family Karrank% is an OpenType font, and 9 corresponding weight levels have been defined.
Here, these numbers correspond to each level, and the keywords normal and bold are assigned to 400 and 700 respectively. In the second example, we consider the font family Zurich, which was mentioned at the beginning of this article. Assume that its font variant is also assigned the weight value below.
Font form: Zurich Light Assigned keywords: empty Assigned numbers: 100,200,300
Font form: Zurich Regular Assigned keywords: normal Assigned numbers: 400
Font form: Zurich Medium Assigned keyword: empty Assigned number: 500
Font form: Zurich Bold Assigned keyword: bold Assigned number: 600,700
Font form: Zurich Black Assigned Keyword: empty Number assigned: 800
Font style: Zurich UltraBlack Keyword assigned: empty Number assigned: 900
The first three numbers are assigned to the lightest font. Normal fonts correspond to keywords 400 and normal.
Medium font is assigned to the number 500. There is no font variant assigned to 600, so 600 and 700 together correspond to the same font variant Bold font. Finally, 800 and 900 are allocated to Black and UltraBlack font variants respectively.
This situation will only occur when the top two thickness levels have been allocated.
Otherwise the user agent may ignore them and assign 800 and 900 to the Bold font, or assign them to one of the two Black font variants. Finally, let's look at the Times font, which has only two font variants, TimesRegulal and TimesBold, as shown below.
Font form: TimesRegular Assigned keywords: normal Assigned numbers: 100,200,300,400,500
Font form: TimesBold Assigned keywords: bold Assigned numbers: 600,700,800,900
Key words The assignment of normal and bold is fairly straightforward. For these numbers, 100 to 300 are assigned to the Regular font, but what about 500? It is assigned to the Regular font because there is no Medium font; so it is the same as 400.
Of the remainder, 700 is always assigned to the bold font, while 800 and 900, due to the lack of bolder fonts, are also assigned to the bold font. Finally, 600 is allocated to the next
Bolder font, of course, only bold font.
The font weight can be inherited. If the paragraph is set to bold, all child elements will inherit the bold font, as follows:
p.one { font-weight:bold; }
The above is the detailed content of Detailed explanation of usage examples of font-weight attribute in css. For more information, please follow other related articles on the PHP Chinese website!

在css中,可用list-style-type属性来去掉ul的圆点标记,语法为“ul{list-style-type:none}”;list-style-type属性可设置列表项标记的类型,当值为“none”可不定义标记,也可去除已有标记。

区别是:css是层叠样式表单,是将样式信息与网页内容分离的一种标记语言,主要用来设计网页的样式,还可以对网页各元素进行格式化;xml是可扩展标记语言,是一种数据存储语言,用于使用简单的标记描述数据,将文档分成许多部件并对这些部件加以标识。

在css中,可以利用cursor属性实现鼠标隐藏效果,该属性用于定义鼠标指针放在一个元素边界范围内时所用的光标形状,当属性值设置为none时,就可以实现鼠标隐藏效果,语法为“元素{cursor:none}”。

在css中,rtl是“right-to-left”的缩写,是从右往左的意思,指的是内联内容从右往左依次排布,是direction属性的一个属性值;该属性规定了文本的方向和书写方向,语法为“元素{direction:rtl}”。

在css中,可以利用“font-style”属性设置i元素不是斜体样式,该属性用于指定文本的字体样式,当属性值设置为“normal”时,会显示元素的标准字体样式,语法为“i元素{font-style:normal}”。

转换方法:1、给英文元素添加“text-transform: uppercase;”样式,可将所有的英文字母都变成大写;2、给英文元素添加“text-transform:capitalize;”样式,可将英文文本中每个单词的首字母变为大写。

在css3中,可以用“transform-origin”属性设置rotate的旋转中心点,该属性可更改转换元素的位置,第一个参数设置x轴的旋转位置,第二个参数设置y轴旋转位置,语法为“transform-origin:x轴位置 y轴位置”。


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

Notepad++7.3.1
Easy-to-use and free code editor

VSCode Windows 64-bit Download
A free and powerful IDE editor launched by Microsoft

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.