HTML教程-HTML<font>标签(在HTML5中不支持)

HTML <font>
标签用于定义其中包含的文本的字体样式。它可以定义HTML文档中文本的字体大小、颜色和字体。
注意:不要使用HTML <font>
标签,因为在HTML5中已被弃用,你可以使用CSS属性来改变字体大小、字体样式、颜色等。
语法
<font size=" " color=" " face=" "> Content....</font>
下面是关于HTML <font>
标签的一些规范
显示 | 内联 |
---|---|
开始标签/结束标签 | 开始和结束标签都存在 |
用法 | 字体样式 |
示例 1
<!DOCTYPE html>
<html>
<head>
<title>Font Tag</title>
</head>
<body>
<h2>Example of font tag</h2>
<p>This is normal text without any font styling</p>
<p>
<font color="blue">Text with normal size and default face</font>
</p>
<p>
<font size="5" color="green">Text with Increased size and default face</font>
</p>
<p>
<font color="red" face="cursive">Text with Changed face</font>
</p>
</body>
</html>
使用CSS
可以使用CSS属性实现与上述示例相同的效果,如下所示:
<!DOCTYPE html>
<html>
<head>
<title>Font Tag</title>
</head>
<body>
<h2>Change font using CSS</h2>
<p>This is normal text without any font styling</p>
<p style="color: blue;">Text with normal size and default face</p>
<p style="font-size: 25px; color: green;">Text with Increased size and default face</p>
<p style="font-family: cursive; color: red;">Text with Changed face</p>
</body>
</html>
属性
标签特定属性
属性 | 值 | 描述 |
---|---|---|
color | rgb(X,X,X) #xxxxx color_name | 指定内容的颜色。 (在HTML5中不支持) |
face | font_family | 指定内容的字体样式。 (在HTML5中不支持) |
size | number | 指定内容的大小。 (在HTML5中不支持) |
支持的浏览器
元素 | ![]() | ![]() | ![]() | ![]() | ![]() |
---|---|---|---|---|---|
<font> | 是 | 是 | 是 | 是 | 是 |