paragraph

</p> is only required in XHTML but not in HTML. Some times you have to close it anyway , eg when you align the paragraph left/right/center.

Would mixing the usage of </p> as in the following be a bad idea? Note that there is no ending </p> tag in the 1st and 3rd paragraph.

<h1>My article</h1>
<p>This is my 1st paragraph.
<p class="align=right">This is my 2nd paragraph</p>
<p>This is my 3rd paragraph.

Reasons why I don't want to close the P-tags:

  • Easy to work with in my CMS (more demanding code to make it XHTML)
  • 1kb lighter files

  • 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.

    链接地址: http://www.djcxy.com/p/88904.html

    上一篇: 什么是HTML中的CDATA?

    下一篇: