Styles - Layout

Structure your page content and elements.

Screen size

Design for mobile first using a single-column layout and work up to wider layouts. Most visitors to the HS2 website are on a mobile device, so it's our first consideration.

The default maximum page width is 960px, but you can make it wider if your content requires it. But lines of text content should be no longer than 70 to 80 characters so that it's easy to read.

Responsive breakpoints

  • mobile: 320px
  • tablet: 641px
  • desktop: 769px
  • large desktop: 990px

Containers

To set up your layout, you will need to create 2 wrappers. The first wrapper is a container which sets the maximum width of the content but does not add any vertical margin or padding.

You can choose from a fixed-width container (960px) or a fluid-width container (which spans the entire width of the viewport).

Container

Use .hs2-width-container for a container with a maximum width of 960px.

Copy default layout code
<div class="hs2-width-container">
  <!-- Main content wrapper here -->
</div>

Fluid container

Use .hs2-width-container-fluid for a full width container, spanning the entire width of the viewport.

Copy fluid layout code
<div class="hs2-width-container-fluid">
  <!-- Main content wrapper here -->
</div>

Main content

The second wrapper is a main element with the class .hs2-main-wrapper, which gives responsive padding to the top and bottom of the page and will be the wrapper for the main content of the page.

There should be only one main element and it should have a unique id of maincontent, which allows keyboard-only users to skip to the main content on a page with the skip link component.

Copy main layout code
<div class="hs2-width-container">
  <main class="hs2-main-wrapper" id="maincontent" role="main">
    <!-- Grid row wrapper here -->
  </main>
</div>

The vertical padding can be made larger or smaller by using the modifier classes .hs2-main-wrapper--l or .hs2-main-wrapper--s. We recommend using smaller vertical padding on transactional services.

Grid system

The grid is structured with a .hs2-grid-row wrapper which acts as a row to contain your grid columns.

You can add columns inside this wrapper to create your layout. To define your columns, add the class beginning with .hs2-grid-column- to a new container followed by the width, for example .hs2-grid-column-one-third, to make it the width you want.

Full width

Open this full width layout example in new window
Copy full width layout code
<div class="hs2-grid-row">
  <div class="hs2-grid-column-full">
    <p>hs2-grid-column-full</p>
  </div>
</div>

One-half

Open this one half layout example in new window
Copy one half layout code
<div class="hs2-grid-row">
  <div class="hs2-grid-column-one-half">
    <p>hs2-grid-column-one-half</p>
  </div>
</div>

Two-thirds

Open this two thirds layout example in new window
Copy two thirds layout code
<div class="hs2-grid-row">
  <div class="hs2-grid-column-two-thirds">
    <p>hs2-grid-column-two-thirds</p>
  </div>
</div>

One-third

Open this one third layout example in new window

Three-quarters

Open this three quarters layout example in new window
Copy three quarters layout code
<div class="hs2-grid-row">
  <div class="hs2-grid-column-three-quarters">
    <p>hs2-grid-column-three-quarters</p>
  </div>
</div>

One-quarter

Open this one quarter layout example in new window
Copy one quarter layout code
<div class="hs2-grid-row">
  <div class="hs2-grid-column-one-quarter">
    <p>hs2-grid-column-one-quarter</p>
  </div>
</div>

Nested grids

Open this nested layout example in new window
Copy nested layout code
<div class="hs2-grid-row">
  <div class="hs2-grid-column-two-thirds">
    <p>hs2-grid-column-two-thirds</p>
    <div class="hs2-grid-row">
      <div class="hs2-grid-column-one-half">
        <p>hs2-grid-column-one-half</p>
      </div>
      <div class="hs2-grid-column-one-half">
        <p>hs2-grid-column-one-half</p>
      </div>
    </div>
  </div>
</div>

Common layouts

Two-thirds in a fixed-width container

Open this two thirds container layout example in new window
Copy two thirds container layout code
<div class="hs2-width-container">
  <main class="hs2-main-wrapper" id="maincontent" role="main">
    <div class="hs2-grid-row">
      <div class="hs2-grid-column-two-thirds">
        <h2>Two-thirds column</h2>
      </div>
    </div>
  </main>
</div>

One-third / two-thirds in a fluid-width container

Open this one third container fluid layout example in new window

Layout utility classes

Reading width

To make it easy to read, lines of text should be no longer than 70 to 80 characters.

When using the fluid-width container or wider grid columns, wrap text content with .hs2-u-reading-width to apply a maximum width and limit the number of characters per line.

Open this reading width layout example in new window
Copy reading width layout code
<div class="hs2-grid-row">
  <div class="hs2-grid-column-full">
    <div class="hs2-u-reading-width">
      <p>This is example content which would exceed 70-80 characters per line, if used within a full width column. The .hs2-u-reading-width utility class will apply a maximum width and limit the number of characters per line.</p>
    </div>
  </div>
</div>

Tablet and mobile specific grid classes

By default, grid columns sizes will go to 100% width of the container on screen sizes below the desktop breakpoint (769px). These utility classes will enforce column widths on all screen sizes.

To define your column sizes, add the utility class .hs2-u- followed by the width to an existing grid column, for example .hs2-u-one-half will set your column width to be one-half on all screen sizes.

Open this tablet mobile layout example in new window
Copy tablet mobile layout code
<div class="hs2-grid-row">
  <div class="hs2-grid-column-one-half hs2-u-one-half">
    <p>hs2-grid-column-one-half hs2-u-one-half</p>
  </div>
</div>

Tablet specific grid classes

These utility classes will enforce column widths on screen sizes above the mobile breakpoint (320px).

To define your column sizes, add the utility class .hs2-u- followed by the width and the suffix -tablet to an existing grid column. For example, .hs2-u-one-third-tablet will set your column width to be one-third on screen sizes tablet and above.

Open this tablet layout example in new window
Copy tablet layout code
<div class="hs2-grid-row">
  <div class="hs2-grid-column-one-third hs2-u-one-third-tablet">
    <p>hs2-grid-column-one-third hs2-u-one-third-tablet</p>
  </div>
</div>