SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Addict
    Join Date
    Oct 2006
    Posts
    301
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Getting Validation Error on my <li>s

    I for some reason I am getting errors validating a section using <li>. The code is below as well as the validation error. Can someone please tell me what I'm doing wrong here?

    Thanks

    Code:
      <div id="sidebar1">
    <ul title="Dog Beds by Style"><h3>Dog Beds by Type</h3>
    <li><a href="/dog-beds/all-dog-beds"><span>All Dog Beds</span></a></li>
    <li><a href="/dog-beds/round-dog-beds"><span>Round Dog Beds</span></a></li>
    <li><a href="/dog-beds/rectangle-dog-beds"><span>Rectangle Dog Beds</span></a></li>
    <li><a href="/dog-beds/orthopedic-dog-beds"><span>Orthopedic Dog Beds</span></a></li>
    <li><a href="/dog-beds/designer-dog-beds"><span>Designer Dog Beds</span></a></li>
    <li><a href="/dog-beds/dog-couches"><span>Dog Couches</span></a></li>
    <li><a href="/dog-beds/donut-dog-beds"><span>Donut Dog Beds</span></a></li>
    <li><a href="/dog-beds/wicker-dog-beds"><span>Wicker Dog Beds</span></a></li>
    <li><a href="/dog-beds/wrought-iron"><span>Wrought Iron</span></a></li>
    <li><a href="/dog-beds/outdoor-dog-beds"><span>Outdoor Dog Beds</span></a></li>
    <li><a href="/dog-beds/water-resistant-dog-beds"><span>Water Resistant Dog Beds</span></a></li>
    <li><a href="/dog-beds/chewproof-dog-beds"><span>Chewproof Dog Beds</span></a></li>
    <li><a href="/dog-beds/heated-dog-beds"><span>Heated Dog Beds</span></a></li>
    <li><a href="/dog-beds/pillow-dog-beds"><span>Pillow Dog Beds</span></a></li>
    <li><a href="/dog-beds/nesting-dog-beds"><span>Nesting Dog Beds</span></a></li>
    <li><a href="/dog-beds/dog-bed-cots"><span>Dog Bed Cots</span></a></li>
    <li><a href="/dog-beds/personalized-dog-beds"><span>Personalized Dog Beds</span></a></li>
    <li><a href="/dog-beds/extra-small-dog-beds"><span>Extra Small Dog Beds</span></a></li>
    <li><a href="/dog-beds/small-dog-beds"><span>Small Dog Beds</span></a></li>
    <li><a href="/dog-beds/medium-dog-beds"><span>Medium Dog Beds</span></a></li>
    <li><a href="/dog-beds/large-dog-beds"><span>Large Dog Beds</span></a></li>
    <li><a href="/dog-beds/extra-large-dog-beds"><span>Extra Large Dog Beds</span></a></li>
    </ul></div>
    # Error Line 142, Column 3: document type does not allow element "li" here; missing one of "ul", "ol" start-tag.
    <li><a href="/dog-beds/all-dog-beds"><span>All Dog Beds</span></a></li>

    The mentioned element is not allowed to appear in the context in which you've placed it; the other mentioned elements are the only ones that are both allowed there and can contain the element mentioned. This might mean that you need a containing element, or possibly that you've forgotten to close a previous element.

    One possible cause for this message is that you have attempted to put a block-level element (such as "<p>" or "<table>") inside an inline element (such as "<a>", "<span>", or "<font>").

  2. #2
    SitePoint Zealot Mahz's Avatar
    Join Date
    Mar 2006
    Posts
    159
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    1) What's the purpose of the <span> tags within each list element?
    2) I'm pretty sure your H3 should be outside your UL.

  3. #3
    SitePoint Addict
    Join Date
    Oct 2006
    Posts
    301
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thank you, that seemed to work. The <span> was there from an example I got by a SEO guy. I was just thinking it was there for SEO purposes. Along with the title= part as well.
    Trying to make the site SEO friendly as well.

  4. #4
    Ripe Tomatos silver trophybronze trophy Rayzur's Avatar
    Join Date
    Jun 2007
    Location
    Texas
    Posts
    4,174
    Mentioned
    4 Post(s)
    Tagged
    0 Thread(s)
    It's OK to put an h3 inside a ul but it must be a list item since only list items are allowed in a ul.

    eg.

    Code:
    <div id="sidebar1">
    <ul title="Dog Beds by Style">
        <li><h3>Dog Beds by Type</h3></li>
        <li><a href="/dog-beds/all-dog-beds"><span>All Dog Beds</span></a></li>
        <li><a href="/dog-beds/round-dog-beds"><span>Round Dog Beds</span></a></li>
        <li><a href="/dog-beds/rectangle-dog-beds"><span>Rectangle Dog Beds</span></a></li>
    And something like this for the css-
    li h3 {
    color:red;
    margin:10px;
    }

    That should validate just fine

  5. #5
    SitePoint Addict
    Join Date
    Oct 2006
    Posts
    301
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I just dropped the <h3> outside of the <ul> and it validated fine. Thanks for your help.


Bookmarks

Posting Permissions

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