- CSS 教程
- CSS - 首页
- CSS - 路线图
- CSS - 简介
- CSS - 语法
- CSS - 选择器
- CSS - 包含
- CSS - 单位
- CSS - 颜色
- CSS - 背景
- CSS - 字体
- CSS - 文本
- CSS - 图片
- CSS - 链接
- CSS - 表格
- CSS - 边框
- CSS - 块级边框
- CSS - 行内边框
- CSS - 外边距
- CSS - 列表
- CSS - 内边距
- CSS - 光标
- CSS - 轮廓
- CSS - 尺寸
- CSS - 滚动条
- CSS - 行内块
- CSS - 下拉菜单
- CSS - 可见性
- CSS - 溢出
- CSS - 清除浮动
- CSS - 浮动
- CSS - 箭头
- CSS - 调整大小
- CSS - 引号
- CSS - 顺序
- CSS - 定位
- CSS - 连字符
- CSS - 悬停
- CSS - 显示
- CSS - 聚焦
- CSS - 缩放
- CSS - 位移
- CSS - 高度
- CSS - 连字符字符
- CSS - 宽度
- CSS - 不透明度
- CSS - Z-Index
- CSS - 底部
- CSS - 导航栏
- CSS - 覆盖层
- CSS - 表单
- CSS - 对齐
- CSS - 图标
- CSS - 图片库
- CSS - 注释
- CSS - 加载器
- CSS - 属性选择器
- CSS - 组合器
- CSS - 根元素
- CSS - 盒模型
- CSS - 计数器
- CSS - 剪裁
- CSS - 书写模式
- CSS - Unicode-bidi
- CSS - min-content
- CSS - 全部
- CSS - 内嵌
- CSS - 隔离
- CSS - 溢出滚动
- CSS - Justify Items
- CSS - Justify Self
- CSS - Tab Size
- CSS - 指针事件
- CSS - Place Content
- CSS - Place Items
- CSS - Place Self
- CSS - 最大块尺寸
- CSS - 最小块尺寸
- CSS - 混合模式
- CSS - 最大内联尺寸
- CSS - 最小内联尺寸
- CSS - 偏移
- CSS - 强调色
- CSS - 用户选择
- CSS 高级
- CSS - 网格
- CSS - 网格布局
- CSS - Flexbox
- CSS - 可见性
- CSS - 定位
- CSS - 图层
- CSS - 伪类
- CSS - 伪元素
- CSS - @规则
- CSS - 文字效果
- CSS - 分页媒体
- CSS - 打印
- CSS - 布局
- CSS - 验证
- CSS - 图片精灵
- CSS - !important
- CSS - 数据类型
- CSS3 教程
- CSS3 - 教程
- CSS - 圆角
- CSS - 边框图片
- CSS - 多重背景
- CSS - 颜色
- CSS - 渐变
- CSS - 盒阴影
- CSS - 盒装饰中断
- CSS - 光标颜色
- CSS - 文本阴影
- CSS - 文本
- CSS - 二维变换
- CSS - 三维变换
- CSS - 过渡
- CSS - 动画
- CSS - 多列
- CSS - 盒尺寸
- CSS - 工具提示
- CSS - 按钮
- CSS - 分页
- CSS - 变量
- CSS - 媒体查询
- CSS - 函数
- CSS - 数学函数
- CSS - 遮罩
- CSS - 形状
- CSS - 样式图片
- CSS - 特异性
- CSS - 自定义属性
- CSS 响应式
- CSS RWD - 简介
- CSS RWD - 视口
- CSS RWD - 网格视图
- CSS RWD - 媒体查询
- CSS RWD - 图片
- CSS RWD - 视频
- CSS RWD - 框架
- CSS 工具
- CSS - PX到EM转换器
- CSS - 颜色选择器和动画
- CSS 资源
- CSS - 有用资源
- CSS - 讨论
CSS - font-weight 属性
CSS font-weight 属性改变元素中字符的视觉粗细。字体粗细指的是字符的厚度或粗细。
语法
font-weight: normal | bold | bolder | lighter | number | initial | inherit;
属性值
| 值 | 描述 |
|---|---|
| normal | 定义普通字体粗细。 |
| bold | 定义粗体字体粗细。 |
| bolder | 定义更粗的字体粗细。 |
| lighter | 定义更细的字体粗细。 |
| 数字 (100-900) | 字体粗细由数字定义,从细到粗。400 等同于 normal,700 等同于 bold。 |
| initial | 将属性设置为其初始值。 |
| inherit | 从父元素继承属性。 |
CSS字体粗细属性示例
以下示例解释了使用不同值的font-weight属性。
使用normal值的字体粗细属性
要将普通字体粗细应用于文本,我们使用normal值。这在以下示例中显示。
示例
<!DOCTYPE html>
<html>
<head>
<style>
p {
font-weight: normal;
}
</style>
</head>
<body>
<h2>
CSS font-weight property
</h2>
<h4>
font-weight: normal
</h4>
<p>
TutorialsPoint offers a wide range of online
tutorials and courses on programming, web development,
and various technology topics. It provides
comprehensive, user-friendly resources for
learners at all skill levels.
</p>
</body>
</html>
使用bold值的字体粗细属性
要将粗体字体粗细应用于文本,我们使用bold值。与normal值相比,字符看起来要粗得多。这在以下示例中显示。
示例
<!DOCTYPE html>
<html>
<head>
<style>
p {
font-weight: bold;
}
</style>
</head>
<body>
<h2>
CSS font-weight property
</h2>
<h4>
font-weight: bold
</h4>
<p>
TutorialsPoint offers a wide range of online
tutorials and courses on programming, web development,
and various technology topics. It provides
comprehensive, user-friendly resources for
learners at all skill levels.
</p>
</body>
</html>
使用bolder值的字体粗细属性
要将更粗的字体粗细应用于文本,我们使用bolder值。使用此值的字符比bold值要粗得多。这在以下示例中显示。
示例
<!DOCTYPE html>
<html>
<head>
<style>
p {
font-weight: bolder;
}
</style>
</head>
<body>
<h2>
CSS font-weight property
</h2>
<h4>
font-weight: bolder
</h4>
<p>
TutorialsPoint offers a wide range of online
tutorials and courses on programming, web development,
and various technology topics. It provides
comprehensive, user-friendly resources for
learners at all skill levels.
</p>
</body>
</html>
使用lighter值的字体粗细属性
要将更细的字体粗细应用于文本,我们使用lighter值。字符看起来很细。这在以下示例中显示。
示例
<!DOCTYPE html>
<html>
<head>
<style>
p {
font-weight: lighter;
}
</style>
</head>
<body>
<h2>
CSS font-weight property
</h2>
<h4>
font-weight: lighter
</h4>
<p>
TutorialsPoint offers a wide range of online
tutorials and courses on programming, web development,
and various technology topics. It provides
comprehensive, user-friendly resources for
learners at all skill levels.
</p>
</body>
</html>
使用数值的字体粗细属性
文本的字体粗细也可以用数值提供。数值可以是100到900,这些表示厚度的递增顺序。以下示例中使用了一些值。
示例
<!DOCTYPE html>
<html>
<head>
<style>
#first {
font-weight: 500;
}
#second{
font-weight: 700;
}
</style>
</head>
<body>
<h2>
CSS font-weight property
</h2>
<h4>
font-weight: 500
</h4>
<p id="first">
TutorialsPoint offers a wide range of online
tutorials and courses on programming, web development,
and various technology topics. It provides
comprehensive, user-friendly resources for
learners at all skill levels.
</p>
<h4>
font-weight: 700
</h4>
<p id="second">
TutorialsPoint offers a wide range of online
tutorials and courses on programming, web development,
and various technology topics. It provides
comprehensive, user-friendly resources for
learners at all skill levels.
</p>
</body>
</html>
支持的浏览器
| 属性 | ![]() |
![]() |
![]() |
![]() |
![]() |
|---|---|---|---|---|---|
| font-weight | 2.0 | 4.0 | 1.0 | 1.3 | 3.5 |
css_properties_reference.htm
广告




