CSS 文本格�


文本格�

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 the "�试一下" link.


文本颜色

颜色属性被用�设置文字的颜色。

颜色是通过CSS最�常的指定:

  • å��六进制值 - 如: #FF0000
  • 一个RGB值 - 如: RGB(255,0,0)
  • 颜色的å��ç§° - 如: red

�阅 CSS 颜色值 查看完整的颜色值。

一个网页的背景颜色是指在主体内的选择:

实例

body {color:red;} h1 {color:#00ff00;} h2 {color:rgb(255,0,0);}

�试一下 »

Remark 对于W3C标准的CSS:如果你定义了颜色属性,你还必须定义背景色属性。


文本的对�方�

文本排列属性是用�设置文本的水平对�方�。

文本�居中或对�到左或�,两端对�.

当text-align设置为"justify",�一行被展开为宽度相等,左,�外边�是对�(如�志和报纸)。

实例

h1 {text-align:center;} p.date {text-align:right;} p.main {text-align:justify;}

�试一下 »


文本修饰

text-decoration 属性用�设置或删除文本的装饰。

从设计的角度看 text-decoration属性主�是用�删除链接的下划线:

实例

a {text-decoration:none;}

�试一下 »

也�以这样装饰文字:

实例

h1 {text-decoration:overline;} h2 {text-decoration:line-through;} h3 {text-decoration:underline;}

�试一下 »

Remark 我们�建议强调指出�是链接的文本,因为这常常混淆用户。


文本转�

文本转�属性是用�指定在一个文本中的大写和�写字�。

�用于所有字���大写或�写字�,或�个��的首字�大写。

实例

p.uppercase {text-transform:uppercase;} p.lowercase {text-transform:lowercase;} p.capitalize {text-transform:capitalize;}

�试一下 »


文本缩进

文本缩进属性是用�指定文本的第一行的缩进。

实例

p {text-indent:50px;}

�试一下 »


Examples

更多实例

指定字符之间的空间
这个例�演示了如何增加或�少字符之间的空间。

指定行与行之间的空间
这个例�演示了如何指定在一个段�中行之间的空间

设置元素的文本方�
这个例�演示了如何改�元素的文本方�。

增加��之间的空白空间
这个例�演示了如何增加一个段�中的��之间的空白空间。

在元素内�用文字环绕
这个例�演示了如何�用一个元素内的文字环绕。

垂直对�图�
这个例�演示了如何设置文本的垂直对�图�。

添加文本阴影
这个例�演示了如何设置文本阴影。


所有CSS文本属性。

属性 �述
color 设置文本颜色
direction 设置文本方�。
letter-spacing 设置字符间�
line-height 设置行高
text-align 对�元素中的文本
text-decoration �文本添加修饰
text-indent 缩进元素中文本的首行
text-shadow 设置文本阴影
text-transform 控制元素中的字�
unicode-bidi 设置或返回文本是�被�写 
vertical-align 设置元素的垂直对�
white-space 设置元素中空白的处�方�
word-spacing 设置字间�