Grow your CSS skills. Land your dream job.

List in a list

  • # July 1, 2008 at 10:51 am

    I need to make a list in a list, for ex.:

    <ul id="cat">
    <li><a href="#">Merginos</a></li>
    <li><a href="#">Vaikinai</a></li>
    <li><a href="#">Auto</a></li>
    <ul>
    <li><a href="#">Audi</a></li>
    <li><a href="#">BMW</a></li>
    <li><a href="#">Mazda</a></li>
    </ul>

    <li><a href="#">Moto</a></li>
    <li><a href="#">Gamta</a></li>
    <li><a href="#">Portretai</a></li>
    <li><a href="#">KelionÄ—s</a></li>
    <li><a href="#">Gyvūnai</a></li>
    <li><a href="#">Namai</a></li>
    </ul>

    But, i can’t pass w3c xhtml valdidate. What’s wrong?

    # July 1, 2008 at 2:52 pm

    The secondary list needs to be contained within the list item that it falls under. So your code should look like this:

    <ul id="cat">
    <li><a href="#">Merginos</a></li>
    <li><a href="#">Vaikinai</a></li>
    <li><a href="#">Auto</a>
    <ul>
    <li><a href="#">Audi</a></li>
    <li><a href="#">BMW</a></li>
    <li><a href="#">Mazda</a></li>
    </ul>
    </li>

    <li><a href="#">Moto</a></li>
    <li><a href="#">Gamta</a></li>
    <li><a href="#">Portretai</a></li>
    <li><a href="#">KelionÄ—s</a></li>
    <li><a href="#">Gyvūnai</a></li>
    <li><a href="#">Namai</a></li>
    </ul>

    Note how the closing </li> for "Auto" comes after the secondary <ul> is opened and closed.

    # July 1, 2008 at 3:13 pm

    Thanks :)

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