Make a Multi-Level CSS Dropdown Menu in Dreamweaver CS4

Step Three: Start Building the CSS

Our menu will belong to CSS class called dropdown. The CSS file will do different things with this dropdown class, depending on whether we are inside the main list, or some secondary or tertiary item. Here’s a quick run down of the components we will style (ul means unordered list and li means list item):

  • ul.dropdown will style the main list (the horizontal bar itself)
  • ul.dropdown li will style an individual within the main list (Home, Visit Us or Animals)
  • ul.dropdown ul will style the vertical column that drops down below Visit Us and Animals.
  • ul.dropdown ul li will style items with that vertical column (e.g. Birds and Beasts)
  • ul.dropdown ul ul will style the menus that pop out to the right of the vertical column (e.g. Kookaburra and Hammerkop for Birds)

Let’s dive in with the first one!

  1. Open the CSS Styles panel (Window > CSS Styles) and click on the New CSS Style icon at the bottom of the panel.
New CSS Style

New CSS Style

  1. In the New CSS Rule box, use these setting and click OK:
    1. Selector Type: Compound (based on your selection)
    2. Selector Name: ul.dropdown
    3. Rule Definition: (New Style Sheet File)
New CSS Rule box

New CSS Rule box

  1. Save the file as menu.css in the same folder as menu.html.
  2. In the “CSS Rule definition for ul.dropdown” box, use these settings and click OK twice:
Category Subcategory Setting Value
Background Background color #cccccc
Box Float left
  Padding (CHECK same for all) Top 0
Margin (CHECK same for all) Top 0
List List-style-type none
List-style-image none
Positioning Position relative
Z-index 597
  1. To see what we’ve done so far, click anywhere in our list on menu.html.
  2. In the Tag Selector, click on the first ul from the left. This will select our entire list.
  3. In the Property Inspector, click on the arrow for Class.
  4. Select the new style we created: dropdown

Apply the dropdown class to the main list

Apply the dropdown class to the main list


Here’s what my menu looks like now:
Menu with the dropdown class applied to it

Menu with the dropdown class applied to it

  1. Click on the New CSS Rule icon again.
  2. In the New CSS Rule box, use these settings and click OK:
    1. Selector Type: Compound (based on your selection)
    2. Selector Name: ul.dropdown a:link
    3. Rule Definition: menu.css
  1. In the “CSS Rule definition for ul.dropdown a:link” box, use these settings and click OK twice:
Category Setting Value
Type Font-family Georgia, "Times New Roman", Times, serif
Color #4a53a2
Text-decoration none
  1. Repeat the settings above for a new compound CSS style called ul.dropdown a:visited

Here’s the menu with the link (and visited link) styles we created:

Menu with new link styles

Menu with new link styles

  1. Repeat steps above for a new compound CSS style called ul.dropdown a:hover, except with black color:
Category Setting Value
Type Font-family Georgia, "Times New Roman", Times, serif
Color #000000
Text-decoration none

To see the effect of the hover setting, save the menu.html file and press F12 to preview the file in a browser. If you get a dialog box asking you to save menu.html, say Yes. If you get a dialog box warning you that some pages have been modified but not saved, that means the new menu.css file; click Yes.

Here, I am hovering over the word Birds in the browser, which changes color to black.

Hover changes the text color to black

Hover changes the text color to black

 

Next: Step Four: CSS Menu Magic

Tagged with: , , ,
Posted in CSS, Dreamweaver, Tutorials
79 comments on “Make a Multi-Level CSS Dropdown Menu in Dreamweaver CS4
  1. Killerwebs says:

    Excellent post, this helped me loads!! thank you

  2. chloe says:

    thank you so so so so so so much

  3. Tinesa says:

    Redoing this site and the only problem I am having is that the dropdown menu under the titles don’t appear. It doesn’t show the dropdown list under About Us, Ministries and Media. Thanks!

  4. Ensys says:

    I have one problem is that, shall we use this HTML Drop-down code for Make dynamic multi-Level CSS Drop-down Menu.

  5. danny3mancom says:

    hello , can you please help me , i`m stuck at making the second , and third level dropdown, i did exactly as you did , except that my list has more items,but everything i do my 2nd and 3rd level wont show , not even in Live View … i don`t know what to do please help me , thanks

  6. Natascha says:

    great article….thanks…..if you have any info at all on how I can create a multi column drop down menu similar to the one at http://www.reuters.com/ where I can put both images, links and text in the drop down menu.

    Thanks in advance….I really appreciate it!

  7. Bud says:

    Excellent tutorial! How do I get the space to the sides of the drop down text links, to also be linkable? Right now only the text is linkable, not the entire 150px wide box.
    Thanks in advance.

  8. Ryan says:

    AWESOME tutorial!!! One thing though, and I am certain it is something that I have not done correctly. Your examples show that when you hover over “beasts”, the “animals” link shares the hover state. When I select a subcategory link, the main navbar link reverts back to the original link state. Do you have any ideas of where I went wrong?? Thanks!
    RL

  9. Kennet says:

    Thx Dawn for wellwritten tutorial. However i miss being able to see the actual HTML-code after finishing step 11 in “design-mode”. Since HTML is what we actually are doing. And because my somehow is not working properly in DW; have to write it with to get indents. As a result im not sure i end up with same code as you..

  10. Jennifer says:

    Thank you so much for this very easy to follow tutorial. I love CSS. I have been wanting a nice, clean, simple drop-down menu and this does it. It beats JavaScript all to heck.

  11. Stephen says:

    Thanks for the post, been having trouble with it for a quite a long time. Although I can’t get the 2nd and 3rd sub menus to appear in the browser and I did it all. Any help would be appreciated. :)

  12. van says:

    that is really a lot of unnecessary steps to add a basic dropdown menu bar. I thought this tutorial was showing hoe to add sound to the navigation links.

  13. Joan says:

    Thanks for the handy tutorial. How can I adapt the tutorial to create a vertical navigation menu?

  14. Don Allen says:

    This is a very helpful article. But, when I go to the CSS Rule box, the Selector Name: does not include ul.dropdown. What am I missing?

  15. Jujubee says:

    Awesome post ! Great help… thank you !

  16. Jujubee says:

    HI, I am sorry but I tought the script was awesome and I still think it is but it doesn’t work in internet Explorer 9. could someone help me, I haven’t seen a post from Dawn for a while now …

  17. Shozib Abbas says:

    Hello Brother! I really appreciate your work on this marvellous tutorial. You have been of great help to me.
    Thanks

  18. William says:

    YOUR INSTRUCTIONS ARE VERY GOOD HOWEVER THE FINALE STAGE, PG4 NO.5 WHEN I DO THIS MY SHOWS EXACTLY AS YOURS BUT THE COPY BUTTON IS GREYED OUT AND I CANNOT MOVE FORWARD, I HAVE HIGHLIGHTED ALL THEN COPY AND PASTED BUT NOTHING WORKS.

    I DID NOT HAVE CSS FOLDER SO JUST CREATED ONE IN THAT NAME. I’VE GONE WRONG SOMEWHERE HAVEN’T I?

    WILLIAM

  19. hello i made ur navMenu. but wen i put on my original Dreamweaver site made by photoshop the Navbar isnt lined up with the banner and doesnt extend all the way with the width of the site.i’ve been messing with it a while but cant seem to get right settings put in

  20. Maria says:

    I tried the Spry Menu in Dreamweaver for a new site I’m creating, but could not get it to work after repeated attempts. Fortunately, I found your wonderful tutorial for which I am very grateful. I just had one problem with it. On page 4, in the section, “Incorporating the Menu into a Page” copying the code with this method didn’t work for me. I went over everything repeatedly, but step 5 was the problem. Only titles copied when I tried the menu.css button below the document tab.
    Is it possible for you to show us where to copy the codes for both menus directly into our code views? Thanks so much for this great tutorial!

  21. Dave says:

    Thanks for the tutorial, I have repeated this tutorial several times from scratch, I keep missing something out but cannot work out what. The main navigation bar looks fine but the text only changes color when directly over the text not the button. Then the sub menus in normal state do not have a background color until hover when the #ccc shows. The same issue carries through to the 3rd menu.

    Could you advise as to which part of the css I should be checking as I obviously missed something important.

    Thanks again

  22. Ryan says:

    i love the tut but have a major problrm. when I click on a link and try to click on the link back it doesnt take me to the same place. for example if i click on my about us page but click on the home page it doesnt have the same path as the first time. Please help

  23. Ab says:

    Hello!

    I just want to ask how to make the third level. Im doing a dropdown menu but I can find how to make the third level in a vertical way. I hope u can answer me. I really desperate!

  24. pranjali says:

    Thank you for this tutorial.
    Its was a great help.
    But i have one question..
    How to attach this file with asp.net?

  25. Jaynne says:

    I followed the instructions and things seemed to work. However, on my new website that I am developing (I am a student) I have an image as the top banner and used image maps for the HOME | ABOUT | PORTFOLIO | CONTACT links. I wanted the drop-down menu for items under the PORTFOLIO link. I am using DW4 and CSS.
    Thanks,Jaynne

  26. Steve says:

    Not sure if Dawn is reading this anymore… but I also cannot ‘unhide’ the second level items. I did it as per the instructions, but setting visibility to visible doesn’t do anything, not even if I make it ‘important’ to override other things. Only thing I did differently to the article was changing settings as I went to make it look like I need for my site – colours etc. but I’ve been through all the previous commands looking for things to do with visibility or placement in the hope of finding the problem, but to no avail.

  27. Dedy Black says:

    i was try this tutorial but the result is error.there’s nothing display second level menu.

  28. Gayathri says:

    You are awesome. Made it so simple and easy. I like very much. Thanks a lot

  29. Hans Stråhle says:

    I have a web site that I wrote in JavaScript and now I want to rebuild it using DW. I am testing this menu system but I have set borders to 4px width. It turns out that the bottom border of a top box and the top border of a first drop down box overlap leaving everything misaligned. I would have liked to attach an image of it but I can’t do that here, can I? What could be the cause of this?

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>