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 8 of 8
  1. #1
    New Coder
    Join Date
    Apr 2005
    Posts
    15
    Thanks
    0
    Thanked 0 Times in 0 Posts

    nested <div> and <li>

    Ive been making my site xhtml-strict compliant and all checks out. I have a question though about nesting div's and li's

    In other words will it be xhtml strict if i do this
    Code:
    <div>
    <ul>
    <li>Item One</li>
    <li>Item Two</li>
        <div>
        <ul>
        <li>Sub Item of Two</li>
        <li>Sub Item of Two</li>
        </ul>
        </div>
    <li>Item Three</li>
    </ul>
    </div>

  • #2
    Smokes a Lot
    Join Date
    Jul 2003
    Location
    CA, USA
    Posts
    1,594
    Thanks
    5
    Thanked 20 Times in 20 Posts
    I think that's just fine, but to be sure, you can always run it through a validator.

    Basscyst
    Helping to build a bigger box. - Adam Matthews

  • #3
    Senior Coder
    Join Date
    Nov 2003
    Location
    Minneapolis, MN
    Posts
    2,879
    Thanks
    2
    Thanked 65 Times in 56 Posts
    If it needs to be a sub item you're better off doing this:
    Code:
    <div>
       <ul>
          <li>Item One</li>
          <li>Item Two
             <ul>
                <li>Sub Item of Two</li>
                <li>Sub Item of Two</li>
             </ul>
          </li>
          <li>Item Three</li>
       </ul>
    </div>

  • #4
    Senior Coder JamieR's Avatar
    Join Date
    Oct 2004
    Location
    United Kingdom
    Posts
    3,161
    Thanks
    0
    Thanked 5 Times in 5 Posts
    Quote Originally Posted by Basscyst
    I think that's just fine, but to be sure, you can always run it through a validator.

    Basscyst
    Nope that code would have produced an error - www.jamierees.co.uk/correct.php

  • #5
    Regular Coder
    Join Date
    Jan 2005
    Location
    Essex
    Posts
    146
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Jamie what good did that do!
    Danny Hayes
    Under Construction www.hayes-design.co.uk

  • #6
    Senior Coder gsnedders's Avatar
    Join Date
    Jan 2004
    Posts
    2,340
    Thanks
    1
    Thanked 7 Times in 7 Posts
    Quote Originally Posted by dannyhayes
    Jamie what good did that do!
    Prove that it fails validation.

    Only one element can be the direct descendent of <ul>/<ol> - <li>.

  • #7
    Smokes a Lot
    Join Date
    Jul 2003
    Location
    CA, USA
    Posts
    1,594
    Thanks
    5
    Thanked 20 Times in 20 Posts
    I stand corrected. I didn't test it, my main point was that simply validating the page will resolve any doubt.

    Basscyst
    Helping to build a bigger box. - Adam Matthews

  • #8
    New Coder
    Join Date
    Apr 2005
    Posts
    15
    Thanks
    0
    Thanked 0 Times in 0 Posts
    It did fail for me also. I guess ill have to do it the right way. no sense in having one page not validate if all the rest do. thanks for your replies


  •  

    Posting Permissions

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