Home arrow Design Usability arrow Page 5 - Easy as A,B,C – dynamic A to Z indexes

Easy as A,B,C – dynamic A to Z indexes

It's a good idea to offer your visitors as many logical ways to navigate your website as possible. This gives them more chances to find exactly the product or information for which they came to your site in the first place. Sitemaps are a wonderful solution, but many of your visitors may find an A to Z index of your site easier to understand. Chris Heilmann explains how to implement such an index.

Author Info:
By: Chris Heilmann
Rating: 4 stars4 stars4 stars4 stars4 stars / 37
March 30, 2005
  1. · Easy as A,B,C – dynamic A to Z indexes
  2. · Our friend the user agent
  3. · The Redmond spoiler
  4. · Making the list dynamic
  5. · Customizing the script

print this article

Easy as A,B,C – dynamic A to Z indexes - Customizing the script
(Page 5 of 5 )

The script needs several classes in the CSS and the appropriate IDs on the HTML element to add the effect. This was done to allow complete control over the look and feel without changing the JavaScript. The IDs make the script a lot faster as we can access elements by their ID rather than looping through all of them.

The IDs are:


The A to Z list navigation; this can be in any format, as the script loops through the links contained within it. The best option is an unnumbered list, though.


The element containing all the different sections from A to Z, normally a DIV.

The classes are:


hides the section to which it is applied


shows the section that was previously hidden


applied to the current link


applied to the atoz element to indicate that the effect should be applied when you mouse over it, and not only when you click it.

All these settings can be changed in the first few lines of the script:

            // check if necessary elements are available

            var n=document.getElementById('atoz');

            var c=document.getElementById('contents');

            // Define the classes in use to show and hide the elements

            var hc='hidden';

            var sc='shown';

            var cc='current';

            var mc='dohover';

Saving even more screen estate

Long lists are boring to look at, and the need to scroll the screen can be very annoying. We aligned our A to Z navigation horizontally; why not do the same with the content lists? All we need to add is a style that defines a width for each of the list elements and floats them to the left:

#contents.columns li{




The link pointing back to the navigation needs to clear each float, otherwise following sections might be indented:

#contents.columns p.back2{



Now we have a dynamic A to Z index that takes up the least possible screen estate (example:columnatoz.html). The list items do get arranged horizontally, not vertically. If we wanted to arrange them vertically, we’d need to resort to more excessive use of CSS and messy HTML suffering from “classitis” (the overuse of classes in the HTML, effectively mixing structure with presentation). There is an article on the subject of multicolumn lists explaining all the ins and outs at Community MX [2].


[1] http://www.jimthatcher.com/skipnav.htm - Internet explorer bug concerning anchors and keyboard navigation.

[2] http://www.communitymx.com/content/article.cfm?cid=27F87  - Multi column lists with CSS.

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.

blog comments powered by Disqus

- Responsive Web Design: More Than Just a Buzz...
- Add New Website Features to Please Users
- Gzip Components in Action
- Configuring Gzip Components
- Gzip Components
- Create Great JavaScript and CSS Menus Simply
- Design Principles that Shape a Web Site
- Creating Aqua Style Images
- Easy as A,B,C – dynamic A to Z indexes
- EasyChart: a Usability Teaching Tool to Demo...
- Building Friendly Pop-up Windows
- Back to School: Design Usability
- Using HTML_QuickForm To Manage Web Forms, Pa...
- Using HTML_QuickForm To Manage Web Forms, Pa...
- More Website Knick Knack

Watch our Tech Videos 
Dev Articles Forums 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us 
Weekly Newsletter
Developer Updates  
Free Website Content 
Contact Us 
Site Map 
Privacy Policy 

Developer Shed Affiliates


© 2003-2019 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap
Popular Web Development Topics
All Web Development Tutorials