HTML <center> 是一个块级元素,其中包含块级和内联内容。<center> 元素之间写入的内容将显示在页面中间。
<center> 标签在 HTML 4 中已被弃用,在 HTML5 中已过时。
<center>在此处添加内容.... </center>
以下是关于 <center> 标签的一些规范
| 展示 | 排队 |
| 开始标签/结束标签 | 开始和结束标签 |
| 用法 | 文字的 |
使用 <center> 标签
<!DOCTYPE html> <html> <head> <title>Center tag</title> </head> <body> <h2>Example of center tag</h2> <center>This content is displayed in the middle of page, but try to use CSS property to align the content as this tag is deprecated now.</center> </body> </html>
使用 CSS
<!DOCTYPE html>
<html>
<head>
<title>Center tag</title>
<style >
h2{
text-align: center;}
</style>
</head>
<body>
<h2>Example of center tag</h2>
<p>This content is align centered using CSS property</p>
</body>
</html>输出:

HTML <center> 标签在 HTML 中不包含任何特定属性,但它支持全局属性(直到 <center> 标签未完全删除)。
| 元素 | Chrome | IE | Firefox | Safari | Opera |
|---|---|---|---|---|---|
| <center> | Yes | Yes | Yes | Yes | Yes |