Class Nav


@Bean(typeName="nav") public class Nav extends HtmlElementMixed
DTO for an HTML <nav> element.

The nav element represents a section of a page that links to other pages or to parts within the same page. It is used to contain navigation links and is typically used for site navigation, table of contents, or pagination. The nav element should contain a list of links and is important for accessibility as it helps screen readers identify the main navigation areas of a page. It is commonly used with ul and li elements to create structured navigation menus.

Examples:

// Simple navigation Nav simple = nav( ul( li(a("/home", "Home")), li(a("/about", "About")), li(a("/contact", "Contact")) ) ); // Nav with styling Nav styled = nav( ul( li(a("/products", "Products")), li(a("/services", "Services")), li(a("/support", "Support")) ) )._class("main-navigation"); // Nav with complex content Nav complex = nav( h3("Site Navigation"), ul( li(a("/home", "Home")), li(a("/about", "About")), li(a("/contact", "Contact")) ) ); // Nav with ID Nav withId = nav( ul( li(a("/home", "Home")), li(a("/about", "About")) ) ).id("main-nav"); // Nav with styling Nav styled2 = nav( ul( li(a("/home", "Home")), li(a("/about", "About")) ) ).style("background-color: #333; padding: 10px;"); // Nav with multiple elements Nav multiple = nav( h3("Navigation"), ul( li(a("/home", "Home")), li(a("/about", "About")) ), p("Use the links above to navigate the site.") ); // Nav with breadcrumbs Nav breadcrumbs = nav( ul( li(a("/", "Home")), li(" > "), li(a("/products", "Products")), li(" > "), li("Current Page") ) );

The following convenience methods are provided for constructing instances of this bean:

See Also: