## 所有CSS文本屬性。
| 屬性 | 描述 |
| :-- | :-- |
| [color](https://www.w3cschool.cn/cssref/pr-text-color.html) | 設置文本顏色 |
| [direction](https://www.w3cschool.cn/cssref/pr-text-direction.html) | 設置文本方向。 |
| [letter-spacing](https://www.w3cschool.cn/cssref/pr-text-letter-spacing.html) | 設置字符間距 |
| [line-height](https://www.w3cschool.cn/cssref/pr-dim-line-height.html) | 設置行高 |
| [text-align](https://www.w3cschool.cn/cssref/pr-text-text-align.html) | 對齊元素中的文本 |
| [text-decoration](https://www.w3cschool.cn/cssref/pr-text-text-decoration.html) | 向文本添加修飾 |
| [text-indent](https://www.w3cschool.cn/cssref/pr-text-text-indent.html) | 縮進元素中文本的首行 |
| [text-shadow](https://www.w3cschool.cn/cssref/css3-pr-text-shadow.html) | 設置文本陰影 |
| [text-transform](https://www.w3cschool.cn/cssref/pr-text-text-transform.html) | 控制元素中的字母 |
| [unicode-bidi](https://www.w3cschool.cn/cssref/pr-text-unicode-bidi.html) | 設置或返回文本是否被重寫? |
| [vertical-align](https://www.w3cschool.cn/cssref/pr-pos-vertical-align.html) | 設置元素的垂直對齊 |
| [white-space](https://www.w3cschool.cn/cssref/pr-text-white-space.html) | 設置元素中空白的處理方式 |
| [word-spacing](https://www.w3cschool.cn/cssref/pr-text-word-spacing.html) | 設置字間距 |
### direction屬性指定文本方向/書寫方向。
JavaScript 語法:object.style.direction="rtl"
| 值 | 描述 |
| --- | --- |
| ltr | 默認。文本方向從左到右。 |
| rtl | 文本方向從右到左。 |
| inherit | 規定應該從父元素繼承 direction 屬性的值。 |
### letter-spacing 屬性增加或減少字符間的空白(字符間距)
JavaScript 語法:object.style.letterSpacing="3px"
| 值 | 描述 |
| --- | --- |
| normal | 默認。規定字符間沒有額外的空間。 |
| *length* | 定義字符間的固定空間(允許使用負值)。 |
| inherit | 規定應該從父元素繼承 letter-spacing 屬性的值。 |
h1 {letter-spacing:2px}
p {letter-spacing:-3px}
### line-height設置以百分比計的行高
JavaScript 語法:object.style.lineHeight="2"
| 值 | 描述 |
| --- | --- |
| normal | 默認。設置合理的行間距。 |
| *number* | 設置數字,此數字會與當前的字體尺寸相乘來設置行間距。 |
| *length* | 設置固定的行間距。 |
| *%* | 基于當前字體尺寸的百分比行間距。 |
| inherit | 規定應該從父元素繼承 line-height 屬性的值。 |
p.small {line-height:90%}
p.big {line-height:200%}
### text-align屬性指定元素文本的水平對齊方式。
JavaScript 語法:object.style.textAlign="right"
| 值 | 描述 |
| --- | --- |
| left | 把文本排列到左邊。默認值:由瀏覽器決定。 |
| right | 把文本排列到右邊。 |
| center | 把文本排列到中間。 |
| justify | 實現兩端對齊文本效果。 |
| inherit | 規定應該從父元素繼承 text-align 屬性的值。 |
### text-decoration 屬性規定添加到文本的修飾。
JavaScript 語法:object.style.textDecoration="overline"
| 值 | 描述 |
| --- | --- |
| none | 默認。定義標準的文本。 |
| underline | 定義文本下的一條線。 |
| overline | 定義文本上的一條線。 |
| line-through | 定義穿過文本下的一條線。 |
| blink | 定義閃爍的文本。 |
| inherit | 規定應該從父元素繼承 text-decoration 屬性的值。
### text-indent 屬性規定文本塊中首行文本的縮進。
JavaScript 語法:object.style.textIndent="50px"
| 值 | 描述 |
| --- | --- |
| *length* | 定義固定的縮進。默認值:0。 |
| *%* | 定義基于父元素寬度的百分比的縮進。 |
| inherit | 規定應該從父元素繼承 text-indent 屬性的值。 |
p { text-indent:50px; }
### text-shadow 屬性應用于陰影文本。
JavaScript 語法:object.style.textShadow="2px 2px #ff0000"
| 值 | 描述 |
| --- | --- |
| *h-shadow* | 必需。水平陰影的位置。允許負值。 |
| *v-shadow* | 必需。垂直陰影的位置。允許負值。 |
| *blur* | 可選。模糊的距離。 |
| *color* | 可選。陰影的顏色。參閱 [CSS 顏色值](https://www.w3cschool.cn/cssref/css-colors-legal.html "CSS 合法顏色值")。 |
h1 { text-shadow: 2px 2px #ff0000; }【W3C中有在線的陰影字體調節】
### text-transform 屬性控制文本的大小寫。
JavaScript 語法:object.style.textTransform="uppercase"
| 值 | 描述 |
| --- | --- |
| none | 默認。定義帶有小寫字母和大寫字母的標準的文本。 |
| capitalize | 文本中的每個單詞以大寫字母開頭。 |
| uppercase | 定義僅有大寫字母。 |
| lowercase | 定義無大寫字母,僅有小寫字母。 |
| inherit | 規定應該從父元素繼承 text-transform 屬性的值。 |
### vertical-align屬性設置一個元素的垂直對齊。
JavaScript 語法:object.style.verticalAlign="bottom"
| 值 | 描述 |
| --- | --- |
| baseline | 默認。元素放置在父元素的基線上。 |
| sub | 垂直對齊文本的下標。 |
| super | 垂直對齊文本的上標 |
| top | 把元素的頂端與行中最高元素的頂端對齊 |
| text-top | 把元素的頂端與父元素字體的頂端對齊 |
| middle | 把此元素放置在父元素的中部。 |
| bottom | 把元素的頂端與行中最低的元素的頂端對齊。 |
| text-bottom | 把元素的底端與父元素字體的底端對齊。 |
| length | ? |
| % | 使用 "line-height" 屬性的百分比值來排列此元素。允許使用負值。 |
| inherit | 規定應該從父元素繼承 vertical-align 屬性的值。 |
### white-space屬性指定元素內的空白怎樣處理。
JavaScript 語法:object.style.whiteSpace="pre"
| 值 | 描述 |
| --- | --- |
| normal | 默認。空白會被瀏覽器忽略。 |
| pre | 空白會被瀏覽器保留。其行為方式類似 HTML 中的 標簽。 |
| nowrap | 文本不會換行,文本會在在同一行上繼續,直到遇到 標簽為止。 |
| pre-wrap | 保留空白符序列,但是正常地進行換行。 |
| pre-line | 合并空白符序列,但是保留換行符。 |
| inherit | 規定應該從父元素繼承 white-space 屬性的值。 |
### word-spacing屬性增加或減少字與字之間的空白。
JavaScript 語法:object.style.wordSpacing="10px"
| 值 | 描述 |
| --- | --- |
| normal | 默認。定義單詞間的標準空間。 |
| *length* | 定義單詞間的固定空間。 |
| inherit | 規定應該從父元素繼承 word-spacing 屬性的值。 |
- 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 選擇器