
2.3 文字样式设置的基本标签
设置字体样式的基本标签是<font></font>,被其包含的文本为样式作用区。
2.3.1 设置文字的颜色
color是<font></font>标签的属性之一,用于设置文字颜色。在D:\web\目录下创建网页文件,命名为font_color.htm,编写代码如代码2.1所示。
代码2.1 字体颜色的设置:font_color.htm。

在浏览器地址栏中输入http://localhost/font_color.htm,浏览效果如图2-1所示。

图2-1 浏览效果
2.3.2 设置文字的尺寸
size也是<font></font>标签的属性,用于设置文字大小。size的值为1~7,默认为3。可以在size属性值之前加上“+”、“-”字符,来指定相对于字号初始值的增量或减量。在D:\web\目录下创建网页文件,命名为font_size.htm,编写代码如代码2.2所示。
代码2.2 文字尺寸的设置:font_size.htm。

浏览效果如图2-2所示。

图2-2 浏览效果(文字尺寸)
2.3.3 设置文字的字体
face也是<font></font>标签的属性,用于设置文字字体(字形)。HTML网页中显示的字形从浏览端的系统中调用,所以,为了保持字形一致,建议采用宋体,HTML页面也默认采用宋体。在D:\web\目录下创建网页文件,命名为font_face.htm,编写代码如代码2.3所示。
代码2.3 字体字形的设置:font_face.htm。

浏览效果如图2-3所示。

图2-3 浏览效果(字体字型)
2.3.4 设置文字效果
1.斜体、粗体、下划线

用双标签<b></b>可使被作用文字加粗,使文字更加醒目,如文章的标题部分。<strong></strong>被称为特别强调标签,也是文字加粗
用双标签<u></u>可添加下划线到被作用文字上,具体代码如代码2.4所示。
代码2.4文字效果的设置。

浏览效果如图2-4所示。

图2-4 浏览效果
2.其他文字效果
<hn>...</hn>用于设定标题字体大小,n=1(大)~6(小)会自动跳下一行。通常用在如章节、段落等标题上。

浏览效果如图2-5所示。

图2-5 浏览效果(其他文字效果)