Header
A header helps users identify where they are and provides a quick, organized way to reach the main sections of a website.
Basic Header
Component Preview
The basic header is displayed at the top of this page. It includes a logo, primary navigation with dropdowns, and a search form.
The header at the top of this documentation site is a live example of the basic header component.
Component Code
<div class="usa-overlay"></div> <header class="usa-header usa-header--basic"> <div class="usa-nav-container"> <div class="usa-navbar"> <div class="usa-logo"> <em class="usa-logo__text"> <a href="/civic-guide/" title="Project title">Project title</a> </em> </div> <button type="button" class="usa-menu-btn">Menu</button> </div> <nav aria-label="Primary navigation" class="usa-nav"> <button type="button" class="usa-nav__close"> <img src="/assets/img/usa-icons/close.svg" role="img" alt="Close" /> </button> <ul class="usa-nav__primary usa-accordion"> <li class="usa-nav__primary-item usa-nav__link"> <button type="button" class="usa-accordion__button usa-nav__link usa-current" aria-expanded="false" aria-controls="basic-nav-section-one"> <span>Current section</span> </button> <ul id="basic-nav-section-one" class="usa-nav__submenu"> <li class="usa-nav__submenu-item"> <a href="#"><span>Navigation link</span></a> </li> </ul> </li> <li class="usa-nav__primary-item usa-nav__link"> <a href="#" class="usa-nav-link"><span>Simple link</span></a> </li> </ul> <section aria-label="Search component"> <form class="usa-search usa-search--small" role="search"> <label class="usa-sr-only" for="search-field">Search</label> <input class="usa-input" id="search-field" type="search" name="search" /> <button class="usa-button" type="submit"> <img src="/assets/img/usa-icons-bg/search--white.svg" class="usa-search__submit-icon" alt="Search" /> </button> </form> </section> </nav> </div> </header>
Extended Header
Component Preview
The extended header allows for more sections in the horizontal navigation and includes a secondary row for additional links or search.
Component Code
<div class="usa-overlay"></div> <header class="usa-header usa-header--extended"> <div class="usa-navbar"> <div class="usa-logo"> <em class="usa-logo__text"> <a href="/civic-guide/" title="Project title">Project title</a> </em> </div> <button type="button" class="usa-menu-btn">Menu</button> </div> <nav aria-label="Primary navigation" class="usa-nav"> <div class="usa-nav__inner"> <button type="button" class="usa-nav__close"> <img src="/assets/img/usa-icons/close.svg" role="img" alt="Close" /> </button> <ul class="usa-nav__primary usa-accordion"> <li class="usa-nav__primary-item usa-nav__link"> <button type="button" class="usa-accordion__button usa-nav__link usa-current" aria-expanded="false" aria-controls="extended-nav-section-one"> <span>Current section</span> </button> <ul id="extended-nav-section-one" class="usa-nav__submenu"> <li class="usa-nav__submenu-item"> <a href="#"><span>Navigation link</span></a> </li> </ul> </li> <li class="usa-nav__primary-item usa-nav__link"> <a href="#" class="usa-nav-link"><span>Simple link</span></a> </li> </ul> <div class="usa-nav__secondary"> <ul class="usa-nav__secondary-links"></ul> <section aria-label="Search component"> <form class="usa-search usa-search--small" role="search"> <label class="usa-sr-only" for="search-field">Search</label> <input class="usa-input" id="search-field" type="search" name="search" /> <button class="usa-button" type="submit"> <img src="/assets/img/usa-icons-bg/search--white.svg" class="usa-search__submit-icon" alt="Search" /> </button> </form> </section> </div> </div> </nav> </header>
Guidance
When to use the header component
- Most websites require header navigation.
- Most websites require some form of navigation to help users find the information they need. While a horizontal navigation bar is just one option for navigation design, it is one of the most visible and familiar ways of helping users navigate a site.
When to consider something else
- Single-page applications or very simple sites.
- If your site has only one page or very limited content, a full header may not be necessary.
Usability guidance
- List all important website sections as links in the horizontal navigation.
- Include all major sections of your site in the navigation.
- Dropdown menus help preview lower-level content.
- For large websites, use dropdown menus to help users preview lower-level content. If lower-level sections are closely related and users will need to quickly jump between them, consider using a side navigation instead of or in addition to a dropdown.
- Use short, clear link labels.
- Don't use jargon or unfamiliar terms.
- Left-justify link labels.
- Left-justified link labels are more easily scannable.
- Present links in priority order.
- Higher-demand links should appear farther to the left, and lower-demand links should appear farther to the right.
- Avoid org-structure navigation.
- Don't model your navigation after your agency's org structure. Instead, structure it according to the tasks and information your users most frequently need to access.
- Highlight the current section.
- Show users where they are within the site by highlighting the current section.
- Always research your navigation.
- Conduct research with your users, and base decisions about your site's information architecture and navigation structure on your findings.
Accessibility guidance
- Add a skip navigation link before the header.
- Include skip navigation links to allow those using screen readers to bypass long navigation lists. Make sure you include an
idat the beginning of your main content and that it matches the skip navigation link. - Ensure your horizontal navigation is keyboard compatible.
- Test to make sure users can use
Tabto navigate andSpace(orEnter) to open pages. - Include tab focus for all top-level navigation items.
- This feature will allow keyboard-reliant users to easily navigate interactive items.
- Avoid using hover to expand dropdown lists.
- Hover is difficult for some users and won't work on touch screens. Dropdowns should expand on click or with keyboard navigation.
- Add context by labelling your nav element.
- If your page has more than one
navelement, use thearia-labelattribute to help assistive technology users understand the purpose of the navigation. - Use list elements for your navigation links.
- This helps screen reader users navigate header content.
- Add alt text to your logo image.
- If you're using a logo that's an image rather than text, make sure you include alternative text for screen readers.
Using the header component
- Include the overlay element.
- Add
<div class="usa-overlay"></div>before the header element to enable the mobile menu overlay. - Load uswds-init.js for best performance.
- We recommend loading
uswds-init.jswhen using banner, header, or modal components to assist in preventing flashes of unstyled content (FOUC) as well as cumulative layout shift (CLS). - Use type="button" on navigation buttons.
- All non-form buttons should have
type="button"to prevent default submit behaviors.
USWDS Documentation
For more guidance, view the USWDS Header Component Documentation.
Settings
| Variable | Description |
|---|---|
$theme-header-font-family
|
Font family of the header. |
$theme-header-logo-text-width
|
Width of the logo text area at desktop width as a percentage of the total header width. |
$theme-header-max-width
|
Maximum width of the header. |
$theme-header-min-width
|
Breakpoint at which the non-mobile header is shown. |
Variants
| Variant | Description |
|---|---|
|
|
Display a simple header. |
|
|
Display a megamenu. Used with basic or extended headers. |
|
|
Display an extended header with more space for sections and secondary navigation. |