Spacer div creating validation problem in ul

Discussion in 'HTML & Website Design' started by jeremyhowell, Jan 23, 2011.

  1. #1
    http://www.jeremyhowellportfolio.com

    In the text Navigation (Home, About Us, etc) I am using a spacer div because I couldn't think of another way to do it as I cant add margins to the menu items as the one on the far right and left would be pushed in or out respectively?

    Can anyone suggest another way to do what I have done here in valid XHTML?

    I hope I am being clear,

    Thanks,

    Jeremy
     
    jeremyhowell, Jan 23, 2011 IP
  2. radiant_luv

    radiant_luv Peon

    Messages:
    1,327
    Likes Received:
    34
    Best Answers:
    1
    Trophy Points:
    0
    #2
    Have a defined margin (margin-left or margin-right) for navigation items <li> and just control margin only for far right/left item using a class.

    Try this,
    
    <ul>
        <li><a href="index.php">Home</a></li>
         
        <li><a href="#">About Me</a></li>
    
        <li><a href="portfolio.php">Portfolio</a></li>
    
        <li class="last""><a href="contact.php">Get In Touch</a></li>
    
      </ul>
    
    Code (markup):
    css
    
    #nav ul li {
    border-bottom-color:#494949;
    border-bottom-style:solid;
    border-bottom-width:1px;
    color:#717171;
    display:inline-block;
    font-family:Verdana,Geneva,sans-serif;
    font-size:11px;
    height:25px;
    list-style-image:none;
    list-style-position:outside;
    list-style-type:none;
    margin-right:59px; [COLOR="red"]<-- Each navigation has equall space at it's right[/COLOR]
    width:125px;
    }
    #nav ul li .last{
    margin-right:0; [COLOR="red"]<-- margin set to 0 as far right not need right margin[/COLOR]
    }
    
    Code (markup):
    Hope this is what you are looking for.
     
    radiant_luv, Jan 23, 2011 IP
  3. jeremyhowell

    jeremyhowell Member

    Messages:
    379
    Likes Received:
    7
    Best Answers:
    2
    Trophy Points:
    45
    #3
    Thanks radiant_luv, I actually didn't think of that of the time, Have just added it and my site is now 100% valid XHTML. Thanks again!
     
    jeremyhowell, Jan 23, 2011 IP