iEntry 10th Anniversary RSS Newsletter Advertising
Visit Twellow.com

Making Accessible Menus in HTML

Post to Twitter Post to Facebook

If you want to make your website validate the WAI or Section 508 accessibility guidelines, you have to separate adjacent links with more than white space.

You actually have to do a whole lot more, but separating links is a big thing, because many menus are violating that rule.

The best way to create a menu is by using unsorted lists and putting the actual link tags inside the list items.

Here's how the HTML could look like:

<ul id="menu">
    <li><a tabindex="1" accesskey="H" href="default.aspx">Home</a></li>
    <li><a tabindex="2" accesskey="C" href="contact.aspx">Contact</a></li>
    <li><a tabindex="3" accesskey="P" href="profile.aspx">Profile</a></li>
    <li><a tabindex="4" accesskey="A" href="about.aspx">About</a></li>
</ul>

This will create a rather ugly list with bullet points, so we have to style it with CSS.

<style type="text/css">
    ul#menu{
      padding: 0px;
      margin: 0px;
      font: 11px verdana;
    }

    ul#menu li{
      display: inline; /* Remove to make vertical */
      width: 70px;
    }

    ul#menu li a{
      text-decoration: none;
      color: navy;
      font-weight: bold;
      padding: 2px 5px;
      /*display: block; make vertical */
    }

    ul#menu li a:hover{
      color: white;
      background: navy;
    }
</style>

View the example

This menu will validate the various accessibility guidelines and is a very clean structure at the same time. I wouldn't dream of creating a menu any other way and, of course, it is cross-browser compatible. Enjoy.

Comments

Add to Del.icio.us | Digg | Reddit | Furl

Bookmark WebProNews:

Mads Kristensen currently works as a Senior Developer at Traceworks located
in Copenhagen, Denmark. Mads graduated from Copenhagen Technical Academy with a multimedia degree in
2003, but has been a professional developer since 2000. His main focus is on ASP.NET but is responsible for Winforms, Windows- and
web services in his daily work as well. A true .NET developer with great passion for the simple solution.

http://www.madskristensen.dk/

About the author:
Mads Kristensen currently works as a Senior Developer at Traceworks located in Copenhagen, Denmark. Mads graduated from Copenhagen Technical Academy with a multimedia degree in 2003, but has been a professional developer since 2000. His main focus is on ASP.NET but is responsible for Winforms, Windows- and web services in his daily work as well. A true .NET developer with great passion for the simple solution.

http://www.madskristensen.dk/

Comments

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.
CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
8 + 1 =
Solve this simple math problem and enter the result. E.g. for 1+3, enter 4.
Featured Headline
Fake Chrome OS Screenshots Punk Tech Media
Mystery Blogger Comes Clean
3 comments | 12 hours ago
 
Subscribe to WebProNews


Send me relevant info