i'm trying to understand nested list and validation.

Discussion in 'CSS' started by driven, Feb 11, 2007.

  1. #1
    I am validating my site. The validator said that i have extra li tags within my nested lists in the sidebar.

    I found this weird because just before uploading my sidebar, this is what I have;

    <div id="sidebar">
    		<ul>
    		
    		<li><h2><a href="#">Back to Homepage</a></h2></li>
     
    		<li><h2>Last Five Entries</h2>
    		<ul>
    	 <li><?php wp_get_archives('type=postbypost&limit=5'); ?></li>
    		</ul></li>
    
    </ul>
    </div>
    Code (markup):
    However, when I view source after uploading, the site says this;

    <div id="sidebar">
    		<ul>
    		
    		<li><h2><a href="#">Back to Homepage</a></h2></li>
     
    		<li><h2>Last Five Entries</h2>
    		<ul>
                     <li>
    	 <li><a href="#">some link text</li>
             <li><a href="#">some link text</li>
    		</ul></li>
                      </li>
    
    </ul>
    </div>
    Code (markup):
    I'm not sure why there is a discrepancy b/w what is in my files before uploading (only one li tag) and what appears on my site (extra li tags).

    So I managed to fix it by getting rid of the extra li tags and the site is now valid.

    However, I am curious to know if my understanding of li tags are offbase to begin with? Was I wrong to have the li tags to begin with since my site is producing the li tags after uploading?

    I hope this makes sense.
     
    driven, Feb 11, 2007 IP
  2. kk5st

    kk5st Prominent Member

    Messages:
    3,497
    Likes Received:
    376
    Best Answers:
    29
    Trophy Points:
    335
    #2
    
    <?php wp_get_archives('type=postbypost&limit=5'); ?>
    Code (markup):
    What, if anything, does that bit of PHP output? I'd say it's the likely source for the extra tags.

    There are good reasons for not intermingling structure (html) with logic (php).

    cheers,

    gary
     
    kk5st, Feb 11, 2007 IP
  3. chopsticks

    chopsticks Active Member

    Messages:
    565
    Likes Received:
    20
    Best Answers:
    0
    Trophy Points:
    60
    #3
    That little bit of php code does according to the wordpress site:
    I think it was wrong to have the li tags there to begin with. According to their examples for their function they don't include any, instead enclosing within <p> tags. So there doesn't really seem to be a reason why they should be there first.
     
    chopsticks, Feb 11, 2007 IP
  4. driven

    driven Well-Known Member

    Messages:
    400
    Likes Received:
    14
    Best Answers:
    0
    Trophy Points:
    138
    #4
    Yes- chopsticks has it correct with Wordpress' function. You only confirm what I thought may have been the reason to begin....a <p> tag or no tag at all is good enough for this. thx again for clarifying this for me.
     
    driven, Feb 12, 2007 IP
  5. Dan Schulz

    Dan Schulz Peon

    Messages:
    6,032
    Likes Received:
    436
    Best Answers:
    0
    Trophy Points:
    0
    #5
    And to think I was going to suggest getting rid of the extra <li> element in your HTML source code, and let the PHP code handle the rest of the output.
     
    Dan Schulz, Feb 12, 2007 IP
    buffalo likes this.
  6. driven

    driven Well-Known Member

    Messages:
    400
    Likes Received:
    14
    Best Answers:
    0
    Trophy Points:
    138
    #6
    I can't quite make out if that's sarcasm or not? :)
     
    driven, Feb 12, 2007 IP
  7. Dan Schulz

    Dan Schulz Peon

    Messages:
    6,032
    Likes Received:
    436
    Best Answers:
    0
    Trophy Points:
    0
    #7
    Bah. Now I see it. Another reason why I like properly formatted HTML code. You can see the relationship between elements and the tags that make them a lot easier.
     
    Dan Schulz, Feb 12, 2007 IP