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 6 of 6
  1. #1
    New Coder
    Join Date
    Sep 2010
    Posts
    45
    Thanks
    2
    Thanked 2 Times in 2 Posts

    Post XHTML Validation Error

    Doc Type:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">


    The Code:

    <li><a href="#" id="M1"><div class="alignment">RESTURANT<br />EQUIPMENT</div></a></li>
    <li><a href="#">SMALLWARES</a></li>
    <li><a href="#" id="M3"><div class="alignment">STORAGE/<br />TRANSPORT</div></a></li>
    <li><a href="#">TABLETOP</a></li>
    <li><a href="#">DISPOSABLES</a></li>
    <li><a href="#">FURNITURE</a></li>
    <li><a href="#">CONSUMABLES</a></li>
    <li class="last-child"><a href="#" id="M8"><div class="alignment">JANITORIAL<br />SUPPLIES</div></a></li>


    Errors:

    document type does not allow element "div" here; missing one of "object", "applet", "map", "iframe", "button", "ins", "del" start-tag


    So how can I write the above HTML to be valid? I need the div's to help control the double line menu... If I put padding on the a tag then my house over image get's padded down so any solution to this so I can have valid code?

  • #2
    Senior Coder
    Join Date
    Aug 2010
    Location
    High Point, NC
    Posts
    3,332
    Thanks
    5
    Thanked 363 Times in 360 Posts
    If you read all the validation explainations the valdiator gives, you can see whats wrong:

    …href="#" id="M1"><div class="alignment">RESTURANT<br />EQUIPMENT</div></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>").
    You cant place a block level element within an inline element.

    You also dont have an opeing and closing <ul></ul> tag.
    Unless you left them out here in your post.

    Now what exactly do you mean by double line menu? Do you mean Drop Down? if so there are many many tutorials to create CSS based DD menus online.
    Teed

  • #3
    New Coder
    Join Date
    Sep 2010
    Posts
    45
    Thanks
    2
    Thanked 2 Times in 2 Posts
    Quote Originally Posted by teedoff View Post
    If you read all the validation explainations the valdiator gives, you can see whats wrong:



    You cant place a block level element within an inline element.

    You also dont have an opeing and closing <ul></ul> tag.
    Unless you left them out here in your post.

    Now what exactly do you mean by double line menu? Do you mean Drop Down? if so there are many many tutorials to create CSS based DD menus online.
    I just left out the ul tags... and I understand whats causing the issue I am just not sure what to do in order to fix it.

  • #4
    Master Coder
    Join Date
    Dec 2007
    Posts
    6,682
    Thanks
    436
    Thanked 890 Times in 879 Posts
    Quote Originally Posted by voloproductions View Post
    I just left out the ul tags... and I understand whats causing the issue I am just not sure what to do in order to fix it.
    very simple, span is also a container, so use span instead of div,

    best regards

  • #5
    Senior Coder
    Join Date
    Aug 2010
    Location
    High Point, NC
    Posts
    3,332
    Thanks
    5
    Thanked 363 Times in 360 Posts
    Thats why I asked what you meant by double line menu? Take out the div tags to fix the validation errors first. You could use the span tag in place of it. Then explain what you're trying to accomplish with this menu or what your desired result should be.
    Teed

  • Users who have thanked teedoff for this post:

    voloproductions (04-05-2011)

  • #6
    New Coder
    Join Date
    Sep 2010
    Posts
    45
    Thanks
    2
    Thanked 2 Times in 2 Posts
    the span tag did what I was trying to accomplish. All fixed now.


  •  

    Posting Permissions

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