Class Nav<T extends Nav<T>>


public class Nav<T extends Nav<T>> extends StyledContainerElement<T>
Represents the HTML <nav> element for navigation links and menus.

The Nav class provides a Java representation of the HTML5 nav element, which defines a section of navigation links. It's intended for major navigation blocks and helps screen readers and search engines identify primary navigation areas.

Features:

  • Semantic HTML5 structural element for navigation
  • Improved accessibility for screen readers
  • Better SEO through semantic markup
  • Can contain lists, links, and other navigation elements
  • Multiple nav elements per document supported
  • Full CSS styling capabilities

Usage Example:


 // Create a main navigation menu
 Nav mainNav = new Nav();
 mainNav.setClass("main-navigation");
 Ul navList = new Ul();
 navList.addElement(new Li(new A("Home", "/")));
 navList.addElement(new Li(new A("Products", "/products")));
 navList.addElement(new Li(new A("About", "/about")));
 navList.addElement(new Li(new A("Contact", "/contact")));
 mainNav.addElement(navList);

 // Create a sidebar navigation
 Nav sideNav = new Nav();
 sideNav.setClass("sidebar-nav");
 sideNav.addElement(new H3("Categories"));
 // Add category links...

 // Create breadcrumb navigation
 Nav breadcrumbs = new Nav();
 breadcrumbs.setClass("breadcrumbs");
 breadcrumbs.addElement(new A("Home", "/"));
 breadcrumbs.addText(" > ");
 breadcrumbs.addElement(new A("Products", "/products"));
 
Since:
2007
Version:
1.0
Author:
Marvin P. Warble Jr.
See Also:
  • Constructor Details

    • Nav

      public Nav()
      Creates a new Nav element for navigation links and menus.