CSS 文本
TEXT FORMATTING
文本格式化
This text is styled with some of the text formatting properties. The heading uses the text-align, text-transform, and color properties. The paragraph is indented, aligned, and the space between characters is specified. The underline is removed from this colored "Try it Yourself" link.
該文本使用某些文本格式屬性來設置樣式。標題使用 text-align、text-transform 和 color 屬性。段落縮進、對齊,并指定了字符間距。然后從這個彩色的“親自試一試”鏈接中刪除了下劃線。
文本顏色
color
屬性用于設置文本的顏色。顏色由以下值指定:
- 顏色名 - 比如 "red"
- 十六進制值 - 比如 "#ff0000"
- RGB 值 - 比如 "rgb(255,0,0)"
查看 CSS 顏色值,以獲取可能顏色值的完整列表。
頁面的默認文本顏色是在 body 選擇器中定義的。
實例
body { color: blue; } h1 { color: green; }
提示:對于 W3C compliant CSS:如果您定義了 color
屬性,則還必須定義 background-color
屬性。
文本顏色和背景色
在本例中,我們定義了 background-color
屬性和 color
屬性:
實例
body { background-color: lightgrey; color: blue; } h1 { background-color: black; color: white; }