HTML
  Home arrow HTML arrow Page 4 - Styling Elements of Nested HTML Lists
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? 
HTML

Styling Elements of Nested HTML Lists
By: Alejandro Gervasio
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 1
    2009-05-22

    Table of Contents:
  • Styling Elements of Nested HTML Lists
  • Review: building basic nested HTML lists
  • Polish the look of nested HTML lists with CSS styles
  • Building a hierarchical navigational system

  • 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


    Styling Elements of Nested HTML Lists - Building a hierarchical navigational system


    (Page 4 of 4 )

    Undoubtedly, this introductory guide on nesting HTML lists wouldn’t be complete if didn't show you how to use them for building a hierarchical navigation bar. Therefore, the last example that I’m going to code will be aimed at creating this links bar, by using some nested lists.

    The sample code that renders this navigational bar on the browser is as follows:

    <!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" />

    <title>Example on building a navigation bar with nested HTML lists</title>

    <style type="text/css">

    body{

    padding: 0;

    margin: 0;

    background: #fff;

    }

    h1{

    font: bold 14pt Arial, Helvetica, sans-serif;

    color: #00f;

    }

    /* style lists */

    ul{

    list-style: outside;

    margin: 0 15px 10px 0;

    }

    /* item lists */

    li{

    font: bold 10pt Arial, Helvetica, sans-serif;

    color: #000;

    }

    /* sub items */

    li li{

    margin: 0 0 5px 0;

    }

    a:link,a:visited{

    font: normal 10pt Arial, Helvetica, sans-serif;

    color: #00f;

    text-decoration: none;

    }

    a:hover{

    text-decoration: underline;

    }

    </style>

    </head>

    <body>

    <h1>Example on building a navigation bar with nested HTML lists</h1>

    <ul>

    <li>List Item 1

    <ul>

    <li><a href="#">Sub Item 1</a></li>

    <li><a href="#">Sub Item 2</a></li>

    <li><a href="#">Sub Item 3</a></li>

    <li><a href="#">Sub Item 4</a></li>

    <li><a href="#">Sub Item 5</a></li>

    </ul>

    </li>

    <li>List Item 2

    <ul>

    <li><a href="#">Sub Item 1</a></li>

    <li><a href="#">Sub Item 2</a></li>

    <li><a href="#">Sub Item 3</a></li>

    <li><a href="#">Sub Item 4</a></li>

    <li><a href="#">Sub Item 5</a></li>

    </ul>

    </li>

    <li>List Item 3

    <ul>

    <li><a href="#">Sub Item 1</a></li>

    <li><a href="#">Sub Item 2</a></li>

    <li><a href="#">Sub Item 3</a></li>

    <li><a href="#">Sub Item 4</a></li>

    <li><a href="#">Sub Item 5</a></li>

    </ul>

    </li>

    <li>List Item 4

    <ul>

    <li><a href="#">Sub Item 1</a></li>

    <li><a href="#">Sub Item 2</a></li>

    <li><a href="#">Sub Item 3</a></li>

    <li><a href="#">Sub Item 4</a></li>

    <li><a href="#">Sub Item 5</a></li>

    </ul>

    </li>

    <li>List Item 5

    <ul>

    <li><a href="#">Sub Item 1</a></li>

    <li><a href="#">Sub Item 2</a></li>

    <li><a href="#">Sub Item 3</a></li>

    <li><a href="#">Sub Item 4</a></li>

    <li><a href="#">Sub Item 5</a></li>

    </ul>

    </li>

    <li>List Item 6

    <ul>

    <li><a href="#">Sub Item 1</a></li>

    <li><a href="#">Sub Item 2</a></li>

    <li><a href="#">Sub Item 3</a></li>

    <li><a href="#">Sub Item 4</a></li>

    <li><a href="#">Sub Item 5</a></li>

    </ul>

    </li>

    </ul>

    </body>

    </html>

    As shown above, a simple navigation mechanism has been built by using some nested HTML lists. Despite its simplicity, this example is actually pretty illustrative. It recreates a real world scenario that you can see on the web every day, where many sites utilize this structure as the building block for seating their links sections.

    In addition to the previous code sample, below I included an extra image that depicts the visual aspect of the links bar just created:



    And lastly, with this hands-on example I’m concluding this article about building HTML lists. As always, feel free to copy and edit all of the code samples included in this tutorial, so you can acquire a more solid grounding in working with these web page elements.

    Final thoughts

    In this second chapter of the series, I showed you a couple of interesting things regarding the use of nested HTML lists in concrete situations, such as enhancing their visual appearance and creating a hierarchical navigation system.

    Naturally, these aren’t the only situations in which nested list can be useful. They can be employed, for instance, for building standard drop-down menus. This will be the topic that I plan to cover in the last part of this series; you won't want to miss it!


    DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware.

       · This second part of the series shows how to enhance the visual appearance of nested...
     

    HTML ARTICLES

    - Comparing Browser Response to Active Client ...
    - Testing Browser Response to Active Client Pa...
    - Active Client Pages: Completing the Code for...
    - ACP and Browsers: Setting up an Example
    - How Browsers Respond to Active Client Pages
    - Completing a Tree with Active Client Pages
    - HTML Form Verification and ACP
    - Building an ACP Tree
    - Completing an ACP 3D HTML Table Image Gallery
    - Building an ACP 3D HTML Table Image Gallery
    - A Multiple Page Image Gallery with Active Cl...
    - Building an Image Gallery with Active Client...
    - Concluding a Menu for All Browsers
    - A Vertical Menu for All Browsers
    - Downloading Long HTML Pages with ACP







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