
- 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
廣告