A navigation bar tells visitors where they can go. Accessibility makes sure that every visitor, whatever their abilities, can find and use the same content.

Building a Navbar

A navbar is a set of links to the main pages of a site. In HTML5 it is written as an unordered list of links, placed inside a <nav> element. A list is the right choice because the links form a group of related items, and screen readers announce the number of items in it.

Definition: Navbar. A set of links, usually inside a nav element, that lets users move between pages.

At this stage, the list shows bullets and runs down the page. CSS, covered in the next unit, removes the bullets and places the items in a row.

Accessibility Basics

Accessibility means designing pages so that people with disabilities can perceive, understand and operate them. This includes people who are blind, people with low vision, people who cannot use a mouse, and people who are deaf.

Definition: Accessibility. Designing pages so that people with disabilities can perceive and use them.

Table 1.10 lists simple practices that remove common barriers.

Table 1.10: Simple accessibility practices

Barrier Practice HTML help
Cannot see images Describe every image alt attribute
Cannot use a mouse Allow keyboard use Links and buttons
Hard to read Strong contrast CSS colours
Unclear structure Headings in order h1 to h6
Unlabelled forms Label every control label element

Web Standards

The W3C publishes the Web Content Accessibility Guidelines, known as WCAG. They are organised around four ideas: content must be perceivable, operable, understandable and robust. Valid HTML that follows the standards works in more browsers and is easier for assistive technology to read. Clear link text also helps, for example Read the syllabus instead of click here.

Example 1.10: A navbar for a college site

<nav>
  <ul>
    <li><a href="index.html">Home</a></li>
    <li><a href="courses.html">Courses</a></li>
    <li><a href="contact.html">Contact</a></li>
  </ul>
</nav>

Output in the browser:

The links form one list inside a nav element. In the next unit CSS will lay them out in a row.

Keep the navbar in the same place on every page so that visitors learn where to look. Use short, clear labels, limit the main menu to about seven items, and mark the current page so that users know where they are. Place the link to the home page first. On small screens long menus are often collapsed behind a menu button, which a later unit builds with Bootstrap. A skip link at the top of the page, such as a link to the main content, lets keyboard users avoid tabbing through the whole menu.

Common mistakes

  • Building a navbar from plain text and spaces instead of a list of links.
  • Using images of text without alt text.
  • Using colours that make the text hard to read.
  • Making an interface that works only with a mouse.

Key takeaways

  • A navbar is a list of links inside a nav element.
  • Accessible pages work for users with different abilities and devices.
  • Alt text, labels, ordered headings and good contrast remove common barriers.
  • WCAG rests on four ideas: perceivable, operable, understandable and robust.

Practice questions

  1. Which element should hold the main navigation links?
  2. Name two practices that make a page more accessible.
  3. What do the letters WCAG stand for?

Answers to the practice questions

  1. The nav element.
  2. For example alt text on images and labels on form controls.
  3. Web Content Accessibility Guidelines.

Sources

  • Official BCA syllabus (NEP 2025 scheme), Web Application Development, course code 25BCA405DS04, Unit I