Strage html代码行为

i have very strange problem:

my site engine uses php. when page created, i view it's HTML code (using broswer's menu "see source html") and i see this (i place here only important part of code):

<div class="main_page_blogs_post2_item1">

            <div><p><p>
    <div class="cblui_image_contaner_" align="center">

but REAL html code differs from source code - when i view this code using firebug, i see this code:

<div class="main_page_blogs_post2_item1">
<div>
<p></p>
<p> </p>
<div class="cblui_image_contaner_" align="center">

i mean that closing </p> tags are autoadded to html code and i d't know why. i thought that it's javascript, but i try to reload page with javascript disabled - it not helps. and i d't thik it's php's fault, cause source code is correct.

UPD: i found out, that in my case 2 opening <p> tags and 2 closing </p> tags have been converted to <p></p> combination. All others <p> tags have not been affected.

What may it be?

Thanks

P.S. sorry for bad english :)

Firebug shows the real generated code in the browser. This might differ (corrected, slightly altered) from the html sent from your server.

There are 3 steps:

  1. Your server code
  2. The generated html
  3. What your browser makes of it (= what you see in firebug)

Firebug displays the source corrected. This means it adds missing tags. The proper way to see the real html is "see source html" in your browser.

While it is technically ok to have open <p> tags, my guess is the browser auto-closes them when encountering the next block tag. Use <br/> tags to add line breaks, or add text to your <p> nodes.

The browser can deal with input like:

<p>Lorem ipsum
<p>Foobar text

And will automatically interpret it as if it read

<p>Lorem ipsum</p>
<p>Foobar text</p>

Thus, your code

<div>
<p><p>
<div> ....

becomes:

<div>
<p></p><p></p>
<div> ....

Try set a HTML doctype and stick with the html/xml rules for it. Make your html error free and test it with the w3c validator. As a rule of thumb, don't use <p> tags without closing them, and don't wrap them around other block tags either.