Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

CSS

Help With My Sub Menu Drop Down.

hello everyone i have some sub menus under Blog And Gallery i just don't know why when i hover over the navbar they do not appear on the bottom of the nav bar. can someone please help me here.

<nav>
  <ul>
    <li><a href="index.html">Home</a></li>
    <li><a href="gallery.html">Gallery</a></li>
      <ul>
        <li><a href="weddings.html">Weddings</a></li>
        <li><a href="engagements.html">Engagements</a></li>
        <li><a href="newborns.html">Newborns</a></li>
          <li><a href="seniors.html">Seniors</a></li>
      </ul>
    <li><a href="clients.html">Client Access</a></li>
    <li><a href="retouch.html">Retouching Services</a></li>
      <ul>
        <li><a href="beforeandafter.html">Before And After</a></li>
        <li><a href="rates.html">Rates</a></li>
      </ul>
      <li><a href="blog.html">Blog</a></li>
      <ul>
      <li><a href="365.html">365 Days</a></li>
      </ul>
    <li><a href="prices.html">Prices</a></li>
    <li><a href="about.html">About</a></li>
    <li><a href="contact.html">Contact</a></li>
    </ul>
</nav>    
nav{
    font-family:Oswald;
    font-size: 1.20em;
    text-align: center;
    margin: 10px auto;
}
nav ul{
padding: 0;
margin: 10px;
list-style:none;
position:relative;
display:inline-table;

}



nav li {
display: inline;
position: relative;
margin: 10px;
}

nav a:hover{
color: #2cb6de;}

nav ul ul {
    display: none;
}
 nav li:hover ul {
    display: block;
}

2 Answers

You have 2 problems.

Firstly your markup is incorrect, this is why you are not experiencing what you expect. Secondly your CSS doesn't quite give the dropdown menu effect. I'll help you with the first but you should try and fix the second on your own. If you need more help i can help with that too.

The markup issue is caused by you closing the list item li too early. When nesting lists as you are you need to wrap the nested ul with the containing li.

Example

<ul>
    <li>
        Menu Item
        <ul>
            <li>Sub Menu Item</li>
        </ul>
    </li>
</ul>

In your code you are closing the list item too early, just after the link, when it should be after the nested list.

  <ul>
    <li><a href="index.html">Home</a></li>
    <li><a href="gallery.html">Gallery</a></li>
      <ul>...</ul>

Here is your code fixed, try and see what the difference is

<nav>
    <ul>
        <li>
            <a href="index.html">Home</a>
        </li>

        <li>
            <a href="gallery.html">Gallery</a>

            <ul>
                <li>
                    <a href="weddings.html">Weddings</a>
                </li>

                <li>
                    <a href="engagements.html">Engagements</a>
                </li>

                <li>
                    <a href="newborns.html">Newborns</a>
                </li>

                <li>
                    <a href="seniors.html">Seniors</a>
                </li>
            </ul>
        </li>

        <li>
            <a href="clients.html">Client Access</a>
        </li>

        <li>
            <a href="retouch.html">Retouching Services</a>

            <ul>
                <li>
                    <a href="beforeandafter.html">Before And After</a>
                </li>

                <li>
                    <a href="rates.html">Rates</a>
                </li>
            </ul>
        </li>

        <li>
            <a href="blog.html">Blog</a>

            <ul>
                <li>
                    <a href="365.html">365 Days</a>
                </li>
            </ul>
        </li>

        <li>
            <a href="prices.html">Prices</a>
        </li>

        <li>
            <a href="about.html">About</a>
        </li>

        <li>
            <a href="contact.html">Contact</a>
        </li>
    </ul>
</nav>

i figured it out thank you