CSS Layout Generator

Instantly generate HTML and CSS boilerplate for common web layouts like the Holy Grail, Sidebar configurations, and Centered Cards.

<div class="container">
  <header>Header</header>
  <div class="content">
    <nav>Nav</nav>
    <main>Main Content</main>
    <aside>Aside</aside>
  </div>
  <footer>Footer</footer>
</div>
.container {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}
.content {
  display: flex;
  flex: 1;
}
header, footer {
  height: 60px;
  background: #eee;
}
nav, aside {
  width: 200px;
  background: #ddd;
}
main {
  flex: 1;
  background: #fff;
}

About the CSS Layout Generator

Pick a classic layout – holy grail, sidebar left, sidebar right or centred card – and copy the matching HTML and CSS to start a page.

Everything you enter is processed in your browser; nothing is uploaded or stored.

How to use it

  1. Choose a layout.
  2. Check the preview of the header, navigation, main content, aside and footer areas.
  3. Copy the HTML Code and CSS Code into your project.

How the layouts are built

The layouts use Flexbox. The holy grail stacks header, content and footer in a full-height column, and the content row holds a fixed-width nav, a flexible main column (flex: 1) and a fixed-width aside. The sidebar layouts keep one fixed-width side column next to a flexible main area.

The centred card uses display: flex with justify-content and align-items set to center on a full-height container – the usual pattern for login and sign-up pages.

Tips

  • Add a media query that sets flex-direction: column below about 768 px so the columns stack on phones.
  • Swap the fixed sidebar widths for a percentage or clamp() value if the sidebar should grow on wide screens.

Frequently asked questions

What is the holy grail layout?

A header, footer, central content column and two sidebars, with the footer staying at the bottom.

Should I use Grid or Flexbox for page layout?

Either works. Flexbox (used here) is simplest for rows or columns; Grid is handy when you need rows and columns at once – see the CSS Grid Generator.

Is the code responsive?

It is a starting point; add a breakpoint to stack the columns on small screens.