Web Standards
  Home arrow Web Standards arrow Page 8 - Get Down With Markup
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? 
WEB STANDARDS

Get Down With Markup
By: Apress Publishing
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 3 stars3 stars3 stars3 stars3 stars / 9
    2005-02-15

    Table of Contents:
  • Get Down With Markup
  • Quiz time
  • Method B: The bullet that bites
  • Method C: Getting closer
  • Method D: Wrapper’s delight
  • Extra credit
  • Getting fancier with custom bullets
  • Lists that navigate
  • Mini-tab shapes

  • 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


    Get Down With Markup - Lists that navigate


    (Page 8 of 9 )

    I’ve shared a few methods of turning unordered lists into horizontal navigation on my personal site (www.simplebits.com), creating tab-like effects using ordinary, structured XHTML—just like the example grocery list.

    For instance, here we’ll take the grocery list and turn it into a navigation bar for an online supermarket (that happens to only sell a handful of items)

    We’d like the navigation in this case to be horizontal and also have some way of highlighting an item when it’s hovered over or selected, creating a tab-like effect.

    First, we’ll add an id to our list so that we can apply specific CSS styles to it. We’ll also make each grocery item a link.

      <ul id="minitabs">
        <li><a href="/apples/">Apples</a></li>
        <li><a href="/spaghetti/">Spaghetti</a></li>
        <li><a href="/greenbeans/">Green Beans</a></li>
        <li><a href="/milk/">Milk</a></li>
      </ul>

    Now, start to add the accompanying CSS:

      #minitabs {
        margin: 0;
        padding: 0 0 20px 10px;
        border-bottom: 1px solid #696;
        }
      #minitabs li {
        margin: 0;
      padding: 0;
      display: inline;
        list-style: none;
      }

    What we’ve done here is essentially turn off bullets and default indenting. We’ve also taken the first step in making the list horizontal, rather than vertical, by setting the display to inline. A bottom border has been added as well to help define the group of links.

    The second step in making the navigation bar horizontal is to float our links to the left. We’ll also style the hyperlinks a little and adjust some padding and margins:

      #minitabs {
        margin: 0;
        padding: 0 0 20px 10px;
        border-bottom: 1px solid #696;
        }
      #minitabs li {
        margin: 0;
        padding: 0;
      display: inline;
      list-style-type: none;
     }
      #minitabs a {
        float: left;
     line-height: 14px;
        font-weight: bold;
        margin: 0 10px 4px 10px;
      text-decoration: none;
      color: #9c9;
        }

    Here we’ve told all a elements within our list to float: left, essentially forcing them all to line up horizontally in a row. We’ve also added some color, made the links bold, and turned off underlines.

    Next, create a tab-like border below the links that is activated when hovered or selected:

      #minitabs {
        margin: 0;
        padding: 0 0 20px 10px;
        border-bottom: 1px solid #696;
        }
      #minitabs li {
        margin: 0;
        padding: 0;
        display: inline;
        list-style-type: none;
        }
      #minitabs a {
        float: left;
        line-height: 14px;
        font-weight: bold;
        margin: 0 10px 4px 10px;
        text-decoration: none;
        color: #9c9;
        }
      #minitabs a.active, #minitabs a:hover {
        border-bottom: 4px solid #696;
        padding-bottom: 2px;
        color: #363;
        }
      #minitabs a:hover {
        color: #696;
        }

    For highlighting and hovering, we’ve added a 4-pixel-tall bottom border to the selected or hovered <li> elements to create a tab-like effect. Highlighted tabs can also be "kept lit" by adding class="active" to the href of our choice:

    <li><a href="/spaghetti/" class="active">spaghetti</a></li>

    This active class shares identical CSS rules with a:hover.

    Figure 1-7 shows the resulting navigation bar.

     

    Figure 1-7.  The resulting mini-tab navigation bar

    I’ve used this method of navigation for my own personal site (www.simplebits.com) as well as on an Inc.com (www.inc.com) redesign in July 2003. Feel free to check the source of these sites for more code examples.

    With some padding and border width adjustments, a variety of different tab-like effects can be achieved, and we’ve done all of this so far using zero images or JavaScript and our basic XHTML-structured grocery list. Hooray for us!

    This chapter is from Web Standards Solutions: The Markup and Style Handbook by Dan Cederhold (Apress, 2004, ISBN:  1590593812). Check it out at your favorite bookstore today. Buy this book now.

    More Web Standards Articles
    More By Apress Publishing


     

    WEB STANDARDS ARTICLES

    - Completing a Configuration for Chrome and a ...
    - Getting Connected with Firefox and Chrome
    - Configuring Servers and Databases with Chrome
    - Configuring Firefox for Chrome and a Server
    - Designing the Elements of a Web Page
    - Matching div heights with CSS and JavaScript
    - Forms
    - Get Down With Markup
    - If I Said You Had a Beautiful Body...
    - Web Standards in Dreamweaver Part 3
    - Web Standards in Dreamweaver, Part 2
    - Web Forms
    - Making Lists Using XHTML
    - Web Standards in Dreamweaver, Part 1







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