P-end-tag (</p>) is not needed in HTML

北城余情 提交于 2019-11-27 02:03:35

P-end-tag is only required in XHTML, not in HTML.

Correct

But some times you have to close it any way eg. when you align the paragraph left/right/center.

Incorrect. The only time you need an explicit end tag is when you want to end the paragraph and immediately follow it by something that is allowed inside a paragraph (such as text or an inline element). This is usually a bad idea.

Would it for any reason be a bad idea to mix the usage of P-end-tag

Only that consistency is a virtue which aids in code maintenance.

I can't think of any reasons why you couldn't do this, but would strongly encourage just using both the beginning and end tags everywhere for consistency. It'll also make it easier for when you do decide to start following the XHTML standards.

You only need to finish the last <p> tag. Example:

<p align="left">Left
<p align="center">Center
<p align="right">Right</p> <!-If you don't put an ending tag, the text will continue in the same line
<p>End</p>

Plus it's faster and reduces the memory of the HTML file.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!