Information

You appear to be using an unsupported browser, and it may not be able to display this site properly. You may wish to upgrade your browser.

Site header

The site header contains key branding and the title of a website. It appears on every page.

Sample HTML

<header class="ds_site-header  ds_site-header--gradient" role="banner">
    <div class="ds_wrapper">
        <div class="ds_site-header__content">
            <div class="ds_site-branding">
                <a class="ds_site-branding__logo  ds_site-branding__link" href="/">
                    <img class="ds_site-branding__logo-image" src="/binaries/content/gallery/designsystem/examples/scottish-government-svg" alt="Scottish Government" />
                </a>

                <div class="ds_site-branding__title">
                    Design System
                </div>
            </div>
        
            <div class="ds_site-header__controls">
                <label aria-controls="mobile-navigation" class="ds_site-header__control  js-toggle-menu" for="menu">
                    <span class="ds_site-header__control-text">Menu</span>
                    <svg class="ds_icon  ds_site-header__control-icon" aria-hidden="true" role="img"><use href="/assets/images/icons/icons.stack.svg#menu"></use></svg>
                    <svg class="ds_icon  ds_site-header__control-icon  ds_site-header__control-icon--active-icon" aria-hidden="true" role="img"><use href="/assets/images/icons/icons.stack.svg#close"></use></svg>
                </label>
            </div>

            <input class="ds_site-navigation__toggle" id="menu" type="checkbox">
            <nav id="mobile-navigation" class="ds_site-navigation  ds_site-navigation--mobile" data-module="ds-mobile-navigation-menu">
                <ul class="ds_site-navigation__list">
                    <li class="ds_site-navigation__item">
                        <a href="#" class="ds_site-navigation__link">
                            Get started
                        </a>
                    </li>
                    <li class="ds_site-navigation__item">
                        <a href="#" class="ds_site-navigation__link">
                            Styles
                        </a>
                    </li>
                    <li class="ds_site-navigation__item">
                        <a href="#" class="ds_site-navigation__link  ds_current">
                            Components
                        </a>
                    </li>
                    <li class="ds_site-navigation__item">
                        <a href="#" class="ds_site-navigation__link">
                            Patterns
                        </a>
                    </li>
                </ul>
            </nav>

            <div class="ds_site-search  ds_site-header__search" data-module="ds-site-search">
                <form role="search" class="ds_site-search__form">
                    <label class="ds_label  visually-hidden" for="site-search">Search</label>
                    <div class="ds_input__wrapper  ds_input__wrapper--has-icon">
                        <input name="q" required="" id="site-search" class="ds_input  ds_site-search__input" type="text" placeholder="Search" autocomplete="off">
                        <button type="submit" class="ds_button  js-site-search-button">
                            <span class="visually-hidden">Search</span>
                            <svg class="ds_icon" aria-hidden="true" role="img"><use href="/assets/images/icons/icons.stack.svg#search"></use></svg>
                        </button>
                    </div>
                </form>
            </div>
        </div>
    </div>

    <div class="ds_site-header__navigation">
        <div class="ds_wrapper">
            <nav class="ds_site-navigation">
                <ul class="ds_site-navigation__list">
                    <li class="ds_site-navigation__item">
                        <a href="#" class="ds_site-navigation__link">
                            Get started
                        </a>
                    </li>
                    <li class="ds_site-navigation__item">
                        <a href="#" class="ds_site-navigation__link">
                            Styles
                        </a>
                    </li>
                    <li class="ds_site-navigation__item">
                        <a href="#" class="ds_site-navigation__link  ds_current">
                            Components
                        </a>
                    </li>
                    <li class="ds_site-navigation__item">
                        <a href="#" class="ds_site-navigation__link">
                            Patterns
                        </a>
                    </li>
                </ul>
            </nav>
        </div>
    </div>
</header>

About this pattern

The site header introduces wider site branding, such as the main colours in a site’s colour palette. It appears at the top of every page and can include an optional search field and primary site navigation.

On a mobile, site navigation is hidden from view until the user clicks or taps on a ‘menu’ button.

Other versions of this pattern

  1. Plain header
  2. Plain header with logo and site title
  3. Header with search
  4. Header with site navigation
  5. Header with search and site navigation
  6. Header with phase banner

Why we use this pattern

The site header helps a user quickly recognise a website, for example if they don’t come to a website via a homepage, or they have multiple tabs open and are switching back and forth between tabs.

We’ve avoided using second level interactive navigation because of usability concerns.

Site branding

The site logo and title can be customised to help users identify which service or organisation site they are using.

This can be formed in variations of:

  • a logo and title separated by a divider
  • only a logo
  • only a title, which can run over one or two lines of text

When the site title appears next to a logo, it should not repeat the name of your brand, but rather be descriptive of the service being provided to the user.

Site branding should always be left aligned and of proportionate size in the site header. We recommend horizontal logos at a maximum height of 40 pixels. Vertically-oriented logos should have a maximum height of 80 pixels.

For the best display of your branding, use vector-based files such as SVG. Alternatively JPG or PNG files can be used but ensure these are of sufficient quality and will not distort.

If you wish to discuss how best to show your site branding please contact designsystem@gov.scot

Evidence

Analytics evidence from mygov.scot and gov.scot shows that users are familiar with the logo as a route to the homepage.

Users were also more likely to navigate to site sections of gov.scot using the site header’s primary navigation than using the same links on panels lower down the homepage.

Website analytics

The site header tracking is available for each of its components: Site searchsite navigation and phase banner. In addition, the logo, title, skip navigation and expandable menu are trackable as follows:

  • Clicks to the title can be tracked through the original page path, the click URL, and a data attribute attached to the title text.

  • Clicks to the logo can be tracked through tracked through the original page path, the click URL, and a data attribute attached to the image.

  • Clicks to ‘Skip to main content’ can be tracked through tracked through the original page path, the click URL, and a data attribute attached to the link.

  • Clicks on the expandable menu can be tracked through the original page path, the click URL, and a data attribute attached to the icon.

The data attributes are added automatically by the Design System’s ‘tracking’ script.

Live example

A Trading Nation (tradingnation.mygov.scot)

Back to top