Overview
The header holds three parts: the top bar, the digital stamp panel and the main navigation. It draws no box of its own. header has display: contents, so its parts sit in the page as if the header were not there.
The links at the end of the page belong in the Footer, and the links inside one section in the Side Menu.
Usage
The code shows the outer element of each part. Copy each part whole from its own page.
Parts
| Part | Holds | Required |
|---|---|---|
header |
The three parts below | Yes |
.nds-topbar |
The top bar: the stamp tab, today’s date, the time or the weather, and the dark mode button. See Top Bar | Yes, on a government site |
#nds-digital-stamp |
The stamp, a top bar expander right after the top bar. The stamp tab opens it. See Digital Stamp | Yes, with the stamp tab |
nav.nds-main-nav |
The main navigation: the brand, the links, the dropdowns and the actions. See Main Navigation | Yes |
Built-in Features
-
Sticky Navigation
The main navigation sticks to the top of the screen while the page scrolls, and the top bar scrolls away. The navigation sticks inside
body, not inside the header, because the header has no box. -
One Panel at a Time
The stamp panel and the main navigation's menu close each other. When one opens, the other closes.
Best Practices
- Style the parts, not the header. Background, padding, borders and the sticky position go on
.nds-topbarand.nds-main-nav. Rules onheaderrender nothing. - The
display: contentsrule hits everyheaderelement on the page, such as an article header in your own markup. Put that header’s styles on a child element, or use adiv. - Use one header per page: the first element in
bodyafter the skip link. See Page Layout. - Keep the parts in the order of the Parts table. The stamp panel opens right below the top bar, and the main navigation comes last.
- Leave the header out of a minimal page, such as sign in or a one-time code. See Page Layout.