## :first-letter 偽元素
## 定義和用法
:first-letter選擇器用來指定元素第一個字母的樣式。
:first-letter是偽元素,它生成包含元素的第一個字母的偽元素。
:first-letter樣式是元素的第一個字母。
任何引導標點符號都應與第一個字母一起設置樣式。
在CSS2.1之前,:first-letter可以只附加到塊級元素。CSS2.1擴展其范圍,包括塊,列表項,表調用,表標題和內聯塊元素。可以應用到首字母的屬性是有限的。
**例子:**
~~~
h1:first-letter {font-size: 166%;}
p:first-letter {text-decoration: underline;}
~~~
**提示:** :first-letter選擇器可以使用以下屬性:?
* font properties
* color properties?
* background properties
* margin properties
* padding properties
* border properties
* text-decoration
* vertical-align (only if float is 'none')
* text-transform
* line-height
* float
* clear
**注意:** "first-letter" 選擇器僅適用于在塊級元素中.
## 實例--每個 元素的第一個字母選擇的樣式:
```
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>W3Cschool教程(w3cschool.cn)</title>
<style>
p:first-letter
{
font-size:200%;
color:#8A2BE2;
}
</style>
</head>
<body>
<h1>Welcome to My Homepage</h1>
<p>My name is Donald.</p>
<p>I live in Duckburg.</p>
<p>My best friend is Mickey.</p>
</body>
</html>
```
- CSS常用樣式控制
- background--背景
- Text--文本
- CSS屬性
- align-*
- animation-*
- appearance
- backface-visibility
- background
- background-attachment
- background-blend-mode
- background-clip
- background-color
- background-image
- background-origin
- background-position
- background-repeat
- background-size
- border
- border-bottom
- border-bottom-color
- border-bottom-left-radius
- border-bottom-right-radius
- border-bottom-style
- border-bottom-width
- border-collapse
- border-color
- border-image
- border-image-outset
- border-image-repeat
- border-image-source
- border-image-width
- Border-left
- border-left-color
- border-left-style
- border-left-width
- border-image-slice
- border-radius
- border-right
- border-right-color
- border-right-style
- border-right-width
- border-spacing
- border-style
- border-top
- border-top-color
- border-top-left-radius
- border-top-right-radius
- border-top-style
- border-top-width
- border-width
- bottom
- box-shadow
- box-sizing
- caption-side
- clear
- clip
- color
- column-count
- column-gap
- column-rule
- column-rule-color
- column-rule-style
- column-rule-width
- column-span
- column-width
- columns
- content
- counter-increment
- counter-reset
- cursor
- direction
- display
- Empty-cells
- filter(濾鏡)
- CSS 偽元素選擇器
- :active 選擇器
- :after 選擇器
- :before 選擇器
- :checked 選擇器
- :disabled 選擇器
- :empty 選擇器
- :enabled 選擇器
- :first-child 偽元素
- :first-letter 偽元素
- :first-line 偽元素
- :first-of-type 選擇器
- :focus 選擇器
- :hover 選擇器