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