Home >Web Front-end >HTML Tutorial >Why can't I use the p tag to set the center?_html/css_WEB-ITnose

Why can't I use the p tag to set the center?_html/css_WEB-ITnose

WBOY
WBOYOriginal
2016-06-24 12:14:142225browse

75598ae0912b4c03dd28a6ab100b9481
ff9c23ada1bcecdd1a0fb5d5a0f18437
> 94b3e26ee717c64999d7867364b1b4a3

The #page I set {width:500px;height:30px;margin:0 auto;}
In IE it is centered, but in Firefox it is not centered ,
Later, I changed e388a4556c0f65e1904146cc1a846bee to dc6dce4a544fdca2df29d5ac0ea9906b or ff6d136ddc5fdfeffaf53ff6ee95f185 and it became centered. I don’t know why? e388a4556c0f65e1904146cc1a846bee is also a block element,



Reply to the discussion (solution)
For p, use


You can use firebug to track it under ff, and the generated document The tree has changed

 text-align : center


p can only contain inline elements, not block elements

<p id="page">   <form>       <input type="text" name="text">   </form></p>被解析成为 以下文档树了,自然不起作用了<p id="page"></p>     <form>      <input name="text" type="text">    </form><p></p>
There are rules for nesting elements, not how you want to nest them

The DOCTYPE definition is missing

Thanks to 2nd floor, I understand

o, bd

Try not to use blocks in P tags!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn