个性化阅读
专注于IT技术分析

HTML center标记(HTML5不支持)

本文概述

HTML <center>是一个块级元素, 其中包含块级和内联内容。在<center>元素之间编写的内容将显示在页面中间。

<center>标记已在HTML 4中弃用, 在HTML5中已过时。

注意:现在不推荐使用<center>标记, 因此可以使用CSS属性text-align:center;代替它。达到相同的结果。

句法

<center>Add Content Here....</center>

以下是有关<center>标签的一些规范

Display Inline
开始日期/结束日期 开始标签和结束标签
Usage textual

使用<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>标记在HTML中不包含任何特定的属性, 但是支持Global Attribute(直到<center>标记没有被完全删除)。

支持的浏览器

Element Chrome IE Firefox Opera Safari
<center> Yes Yes Yes Yes Yes
赞(0)
未经允许不得转载:srcmini » HTML center标记(HTML5不支持)

评论 抢沙发

评论前必须登录!