CSS ::first-letter 偽元素
示例
選擇每個 <p> 元素的第一個字母並設定其樣式
p::first-letter {
font-size: 200%;
font-weight: bold;
color: #8A2BE2;
}
自己動手試一試 »
定義和用法
::first-letter
偽元素用於為塊級元素的第一個字母設定樣式。
注意: 以下屬性可與 ::first-letter 一起使用
- 所有字型屬性
- 所有 background 屬性
- 所有 margin 屬性
- 所有 padding 屬性
- 所有 border 屬性
- color
- text-decoration
- text-shadow
- letter-spacing
- word-spacing
- text-transform
- text-decoration-color
- text-decoration-line
- text-decoration-style
- box-shadow
- vertical-align (僅當 float 為 'none' 時)
- line-height
- float
版本 | CSS1 |
---|
瀏覽器支援
表中數字表示首次完全支援此偽元素的瀏覽器版本。
偽元素 | |||||
---|---|---|---|---|---|
::first-letter | 1.0 | 9.0 | 1.0 | 1.0 | 7.0 |
CSS 語法
相關頁面
CSS 教程:CSS 偽元素