为什么Chrome的Elements检查器中会显示一些额外的“<p> </p>”标记?

时间:2013-12-31 01:33:23

标签: html

为什么Chrome的“元素”检查器中会显示一些额外的<p></p>标记?

以下是截图:

enter image description here

源代码是这样的;

<div class="hint">
  <p><center class="hint-title">Tips</center></p>
</div>

感谢任何提示!

1 个答案:

答案 0 :(得分:3)

由于您使用的是无效标记<center>

,因此会添加额外的标记
<center></center> is not in HTML5.

要在html代码中居中文字,请使用text-align:center;像这样

 <p class="hint-title" style="text-align: center;">Tips</p>

使用css样式表中的类居中文本执行此操作

.hint-title { text-align: center; }

http://www.w3schools.com/tags/tag_center.asp