Style Sheets
  Home arrow Style Sheets arrow Page 2 - Building Clean Drop-Down Menus with CSS
Dev Articles Forums 
ADO.NET  
Apache  
ASP  
ASP.NET  
C#  
C++  
ColdFusion  
COM/COM+  
Delphi-Kylix  
Design Usability  
Development Cycles  
DHTML  
Embedded Tools  
Flash  
Graphic Design  
HTML  
IIS  
Interviews  
Java  
JavaScript  
MySQL  
Oracle  
Photoshop  
PHP  
Reviews  
Ruby-on-Rails  
SQL  
SQL Server  
Style Sheets  
VB.Net  
Visual Basic  
Web Authoring  
Web Services  
Web Standards  
XML  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
STYLE SHEETS

Building Clean Drop-Down Menus with CSS
By: Alejandro Gervasio
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 2
    2008-10-15

    Table of Contents:
  • Building Clean Drop-Down Menus with CSS
  • Building the drop-down menu's structural markup
  • Adding some useful CSS styles to make the menu work
  • Seeing the completed drop-down menu in action

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    Building Clean Drop-Down Menus with CSS - Building the drop-down menu's structural markup


    (Page 2 of 4 )

    A good point to begin developing this CSS-based drop-down menu is with defining its structural markup, which will be used to display on the browser the top-level item of the menu and the corresponding sub-items. To do so, I'm going to use as a starting point the excellent implementation of Peter Took's drop-down menu, and later I will introduce my own modifications to the whole navigational system.

    Thus, having clarified that, the (X)HTML markup that will compose the menu will look similar to that shown in the below example:


    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

    <html xmlns="http://www.w3.org/1999/xhtml">

    <head>

    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />

    </head>

    <body>

    <ul>

    <li>About Us

    <ul>

    <li><a href="">Our Staff</a></li>

    <li><a href="">Why work with us?</a></li>

    <li><a href="">Our profile</a></li>

    <li><a href="">More details</a></li>

    </ul>

    </li>

    <li>Services

    <ul>

    <li><a href="">Graphic Design</a></li>

    <li><a href="">Web Design</a></li>

    <li><a href="">Web Programming</a></li>

    <li><a href="">Software Development</a></li>

    </ul>

    </li>

    <li>Products

    <ul>

    <li><a href="">Simple AJAX Library</a></li>

    <li><a href="">PHP Form Validator</a></li>

    <li><a href="">PHP MySQL Connector</a></li>

    <li><a href="">PHP Easy Pager</a></li>

    <li><a href="">PHP Form Factory</a></li>

    </ul>

    </li>

    </ul>

    </body>

    </html>


    Not too difficult to grasp, right? As you can see, the bare bones structure of this CSS-based menu is comprised of a well-structured unordered list, where each of the respective sub-menus is also wrapped by another list. Definitely, at this point you'll have to agree with me that the structural markup of the prior menu looks clean and tight, and offers remarkable accessibility.

    So, having defined the basic structural markup of the menu that you saw earlier, what's the next step? Well, as you might have guessed, the menu is still at a very primitive stage; it requires the definition of some important CSS styles, which will make it work as expected.

    Therefore, and assuming that you're still interested in learning how the previous menu can be turned into a fully-functional piece of code, in the course of the following section I'm going to declare a few simple CSS styles to spice up the visual appearance of the menu itself, and more importantly, to make it work adequately.

    To find out more on how all of these tasks will be performed, please jump ahead and read the next few lines. I'll be there, waiting for you.

    More Style Sheets Articles
    More By Alejandro Gervasio


       · Building standard drop-down menus with CSS is a pretty straightforward task,...
       · It doesn't work on IE6 though
       · Thanks for the comments, but I guess you didn’t read the entire article, simply...
       · hallo,thanks for the article.one question, maybe newbie:the titles of the <a hrefs>...
       · Thanks for the comments. You can change the width of the menu by modifying the ul...
       · tried the code in ie7 we are developing with ref to mozilla so wanted a solution to...
       · You must be doing something wrong, since the menu works fine most browsers,...
     

    STYLE SHEETS ARTICLES

    - Image Replacement CSS Techniques
    - Using BlueTrip`s Success, Notice and Error C...
    - More Uses for the Thin and Caps CSS Classes ...
    - Styling Definition Lists with the BlueTrip C...
    - Styling Unordered and Ordered HTML Lists wit...
    - Using the BlueTrip CSS Framework`s Thin and ...
    - Adding Borders to Web Page Columns with Blue...
    - Introducing the BlueTrip CSS Framework
    - Using a Background Grid to Assist Web Page L...
    - Extending the Rule Of Thirds for Web Page La...
    - A Two-Column Web Page Layout Based on the Ru...
    - Using the Rule Of Thirds for Web Page Layout
    - Swapping Columns Using the Divine Ratio for ...
    - Using the Golden Ratio in Liquid Web Page De...
    - Fundamental Design Principles for Web Page L...







    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 4 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek