CSS 的font-weight属性用于设置与 HTML 文本一起使用的字体的粗细。应用的字体粗细将取决于使用的字体系列和浏览器。例如,某些字体系列仅适用于特定的权重。
句法:
font-weight: normal | bold | lighter | bolder | number | initial |
inherit | unset;
关键字值:
- normal:这定义了正常字体粗细(默认字体粗细)。它等于数字值400 。
- 粗体:这定义了粗体字重,它等于数字值700 。
相对关键字值:
- 更轻:考虑到字体系列的可用字体粗细,这使得字体粗细比父元素轻一级。
- 更粗:考虑到字体系列的可用字体粗细,这使得字体粗细比父元素重一级。
数值:
- 数字:根据指定的数字设置字体粗细。该数字的范围在1到1000之间。如果无法获得准确的重量,则应用合适的重量。
全球价值观:
- 初始:这将字体粗细设置为初始(默认)值。
- 继承:这将字体粗细设置为等于从其父元素继承的值。
- unset:这将字体粗细设置为等于从其父元素继承的值,因为font-weight是可继承的属性。
示例:
font-weight property
Prepare for the Recruitment drive of product
based companies like Microsoft, Amazon, Adobe
etc with a free online placement preparation
course. The course focuses on various MCQ's
& Coding question likely to be asked in the
interviews & make your upcoming placement
season efficient and successful.
Prepare for the Recruitment drive of product
based companies like Microsoft, Amazon, Adobe
etc with a free online placement preparation
course. The course focuses on various MCQ's
& Coding question likely to be asked in the
interviews & make your upcoming placement
season efficient and successful.
Prepare for the Recruitment drive of product
based companies like Microsoft, Amazon, Adobe
etc with a free online placement preparation
course. The course focuses on various MCQ's
& Coding question likely to be asked in the
interviews & make your upcoming placement
season efficient and successful.
Prepare for the Recruitment drive of product
based companies like Microsoft, Amazon, Adobe
etc with a free online placement preparation
course. The course focuses on various MCQ's
& Coding question likely to be asked in the
interviews & make your upcoming placement
season efficient and successful.
输出:
支持的浏览器: CSS支持的浏览器 | font-weight 属性如下:
- 谷歌浏览器 2.0
- 浏览器 4.0
- 火狐 1.0
- Safari 1.3
- 歌剧 3.5
参考: Mozilla 开发者网络 (MDN)
如果您发现任何错误或有改进建议,请在下面发表评论。