Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New Coder
    Join Date
    Dec 2006
    Posts
    36
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Very strange problem with dreamweaver

    I have this bit of code:
    Code:
                    <td class="menubody"><p><ul>
                      <li>Homepage</li>
                      <li>Blog</li>
                      <li>Downloads</li>
                      <li>Pictures</li>
                    </ul></p></td>
    And I save it, and when i open the page in FF, and look at the sourcecode, it says:

    Code:
                    <td class="menubody"><p></p><ul>
                      <li>Homepage</li>
                      <li>Blog</li>
                      <li>Downloads</li>
                      <li>Pictures</li>
                    </ul></td>
    As you can see, the <p>tags are.. misplaced! How did it do that? It's not that it doesnt save correctly because i'm sure I never put in <p></p> anywhere...

  • #2
    Regular Coder croatiankid's Avatar
    Join Date
    Jan 2006
    Posts
    665
    Thanks
    1
    Thanked 12 Times in 12 Posts
    It's because UL is a block level element, and inline elements (like P) cannot contain block level elements. You are probably using an XHTML DOCTYPE, in which case all tags (including P) must be closed, so the P is automatically closed. If you check out http://www.croatiankid.com/design.php, you'll see that before my UL I have a P, and it appears that the P is not closed anywhere, and therefore doesn't validate, but because of the DOCTYPE I used, the P is automatically closed before the UL, except here you can't see it closed because in HTML Ps don't have to be closed (I think...), but I still close it wherever I need, like on the other pages of the site.

  • #3
    Regular Coder croatiankid's Avatar
    Join Date
    Jan 2006
    Posts
    665
    Thanks
    1
    Thanked 12 Times in 12 Posts
    Also, because of what I explained above,
    Code:
                    <td class="menubody"><p><ul>
                      <li>Homepage</li>
                      <li>Blog</li>
                      <li>Downloads</li>
                      <li>Pictures</li>
                    </ul></p></td>
    would not validate, because the P would automatically close itself in the browser before the UL, and the /P would be redundant (unneccessary, since the P is actually already closed)

  • #4
    The fat guy next door VIPStephan's Avatar
    Join Date
    Jan 2006
    Location
    Halle (Saale), Germany
    Posts
    8,680
    Thanks
    6
    Thanked 1,009 Times in 982 Posts
    Quote Originally Posted by croatiankid View Post
    It's because UL is a block level element, and inline elements (like P) cannot contain block level elements.
    It's true that inline elements cannot contain block elements, however, a paragraph is a block element as well. Only they can't contain lists, which the internal validator of Dreamweaver should tell you if you validate.
    It might be that you have some kind of code correction enabled so Dreamweaver will automatically correct wrong code (hence, close a paragraph that wrongly contains a list).


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •