Grow your CSS skills. Land your dream job.

XHTML Validation help

  • # August 2, 2008 at 4:43 pm

    Alright, I can’t for the life of me figure out what I’m supposed to do to make this valid and still work. I recently rebuilt stupid5pin.com in WordPress using CMS and XHTML. I did a custom front page based off of a tutorial I found on PlayWorkPlay, which I had to tweak the hell out of to get to work. Every other page on my site will easily pass validation but the front page won’t. So the following is my code for the entire page, and the output it’s giving me when I try to validate it:

    Code:
    < ?php get_header(); ?>

      < ?
      $categories = get_categories('hide_empty=0&order=DESC&orderby=id');
      foreach ($categories as $cat) { ?>

      Latest Item in < ? echo $cat->name; ?>
      More Recent Items in < ? echo $cat->name; ?>

      < ?php
      $catID = $cat->cat_ID;
      query_posts(“showposts=8&cat=$catID”);
      $first=1;
      $ul=0;
      while (have_posts()) : the_post();
      // Latest post with excerpt
      if($first) {
      ?>

      “>< ?php the_title(); ?>

      < ?php the_excerpt(); ?>

      < ?php
      $first=0;
      } // end if
      else {
      if ($ul==0) {
      echo '

      ‘ ?>


      < ?php } //end foreach ?>

    < ?php get_sidebar(); ?>
    < ?php get_footer(); ?>

    and the error messages:

    Code:
    Validation Output: 2 Errors

    1. Error Line 41, Column 24: document type does not allow element “div” here; assuming missing “li” start-tag .

    ✉
    2. Error Line 116, Column 6: end tag for “li” omitted, but OMITTAG NO was specified .

    ✉

    You may have neglected to close an element, or perhaps you meant to “self-close” an element, that is, ending it with “/>” instead of “>”.
    3. Info Line 41, Column 2: start tag was here .

    Anybody have any idea what I’m supposed to put where to make this code valid without breaking my layout? (BTW if anybody’s wondering, I put the style elements directly in this document because this is the only page that any of these particular styles are a part of)

    box
    # August 2, 2008 at 7:34 pm

    UL elements must contain <li> only. Those <li> can contain what you like.

    You have a <ul> containing <div> elements and that simply isn’t allowed.

    Remove
    <ul id="cat-listing" style="border:2px solid black;"> (– on line 40)
    and its partnering </ul> (– on line 116) and that should fix the validation. You will have to restyle – but then you shouldn’t really be using inline styling anyway ;)

    # August 2, 2008 at 10:45 pm

    Awesome, that worked perfectly. Got it still looking the same, and validating. And as I stated, I only used inline styling on here because these elements are only used on this page. Didn’t see the use in adding stuff to the stylesheet that only effects one page.

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.

*May or may not contain any actual "CSS" or "Tricks".