GPT 5 Available DeepSeek V4 Available Kimi K2.6 Available GPT 5 Mini Available DeepSeek V3.2 Available GPT 5.4 Available GPT 5.4 mini Available Grok 4 Available Llama 3.1 Available Phi 4 Available GLM 5.2 by Z.ai Available Claude Haiku 5.5 Available
Free AI chat models, no sign upSee all chat models →
Buy me a coffee
GPT 5 Available DeepSeek V4 Available Kimi K2.6 Available GPT 5 Mini Available DeepSeek V3.2 Available GPT 5.4 Available GPT 5.4 mini Available Grok 4 Available Llama 3.1 Available Phi 4 Available GLM 5.2 by Z.ai Available Claude Haiku 5.5 Available
Free AI chat models, no sign upSee all chat models →
Free AI Layout Generator

Generate Responsive Page Layouts

Create responsive page layouts for a blog, a dashboard or a landing page for free with AIFreeForever's AI Layout Generator. Each layout comes as HTML and CSS with breakpoints and a live preview.

Pick the layout technique and breakpoints to generate your layoutPick the technique and breakpoints
Layout Technique
Responsive Breakpoints
Describe the layout you need
Quick layout techniques you can choose from

What is AI Layout Generator

Centered featured hero for an Ai Layout Generator showing a sleek UI panel with Page size input, layout type dropdown, grid snapping toggle, and Generate button, over a designer workspace background with wireframes and subtle grid lines.

This tool generates complete responsive layouts using CSS Grid, Flexbox, or hybrid approaches. Get HTML structure and CSS with mobile-first design and multiple breakpoints.

AI Layout GeneratorMade by AIFreeForever
Generate my layout free
DetailInformation
ToolAI Layout Generator by AIFreeForever
InputDescribe the layout in the chat box
TechniquesCSS Grid, Flexbox, Grid + Flexbox Hybrid and more
BreakpointsMobile First (3), Desktop First (3), Custom (5)
OutputOne HTML page with its CSS, as layout.html
PricingFree

Why Use the AI Layout Generator?

Planning a page's grid and media queries by hand takes time. The AI Layout Generator writes the HTML and CSS for you. It runs on several AI models you can switch between and compare, such as Claude Haiku 5.5, GPT-6 Luna and more.

  • AIFreeForever's AI Layout Generator is free to use.
  • No login, no sign up for your first few messages.
  • After that, you may be asked to verify your email with a one-time code.

How to Use AI Layout Generator

Follow these simple steps to use the ai layout generator:

  1. 1

    Describe in the chat box the regions your page needs, such as a header, sidebar, main content and footer.

  2. 2

    Pick CSS Grid, Flexbox, Grid + Flexbox Hybrid or Float (Legacy) under Layout Technique on the settings card.

  3. 3

    Choose Mobile First, Desktop First or Custom under Responsive Breakpoints to match how your layout should adapt.

  4. 4

    Press Generate Layout to receive one HTML page with its CSS, then open the Preview to see it working.

  5. 5

    Copy the code or download layout.html, adjust the spacing values and replace the placeholder content in each region.

The Responsive Layout Cheat Sheet, 2026Free PDF with common breakpoint widths and a request template for the AI Layout Generator. It also has a checklist to test a layout at every screen size. Download free PDF

CSS Grid vs Flexbox vs Float Layouts

AIFreeForever's AI Layout Generator builds your responsive page with the layout technique you pick in the settings card.

CSS Grid

The page's regions are placed with named grid-template-areas, fr columns and gap. It suits a page with rows and columns at once.

Mobile First vs Desktop First Breakpoints

AIFreeForever's AI Layout Generator lets you pick how the layout changes from phones to desktops, and the media queries in your code follow that choice.

StrategyHow the layout changesBreakpointsTry it
Mobile First (3 breakpoints) The layout starts as a one-column phone view and adds columns at 640px, 1024px and 1280px. This suits a site most people open on a phone. 640px1024px1280px
Desktop First (3 breakpoints) The layout starts as a full desktop view and removes columns at 1279px, 1023px and 639px. This suits a desktop site or web app being made responsive. 1279px1023px639px
Custom (5 breakpoints) The layout changes at 480px, 640px and 768px. It also changes at 1024px and 1280px, or at the widths you name. This suits a design that needs its own widths. 480px640px768px1024px1280px

Examples of Content Generated by AI Layout Generator

The four examples are real layouts made by AIFreeForever's AI Layout Generator, each drawn working beside its HTML and CSS. They help web designers, developers and students who want a page structure to copy and fill with their own content. Pressing Generate Layout like this puts the example's description, technique and breakpoints on the settings card.

Here are some examples of what you can create with our tool:

Two-column blog with sticky sidebar

A two-column blog layout with a header, the posts in the main column, a sticky sidebar with categories and recent posts, and a footer

CSS Grid · Mobile First · 171 lines
<!doctype html>
<!-- Layout: two-column blog with CSS Grid, named grid-template-areas -->
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Blog layout</title>
<style>
/* Variables: colours and spacing */
:root {
  --bg: #f6f5f1;
  --header-bg: #2f3e46;
  --header-text: #fdfdfd;
  --nav-bg: #e3e0d5;
  --main-bg: #ffffff;
  --aside-bg: #eef3f8;
  --footer-bg: #dfe3e6;
  --card-bg: #f4e9e0;
  --text: #22272b;
  --muted: #55606a;
  --border: #cfd4d8;
  --radius: 0.5rem;
  --space-1: 0.5rem;
  --space-2: 1rem;
  --space-3: 1.5rem;
}
/* Base: reset box model and typography */
*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; font-family: system-ui, sans-serif; line-height: 1.6; color: var(--text); background: var(--bg); font-size: 1rem; }
h1, h2, h3 { line-height: 1.25; margin: 0 0 var(--space-2); }
p { margin: 0 0 var(--space-2); }
/* Accessibility: skip link and focus style */
.skip-link { position: absolute; left: -999px; top: 0; background: var(--header-bg); color: var(--header-text); padding: var(--space-1) var(--space-2); }
.skip-link:focus { left: var(--space-1); }
a:focus-visible, .menu-toggle:focus-visible { outline: 3px solid #1c6dd0; outline-offset: 2px; }
/* Layout: page grid with named areas (mobile: one column) */
.page {
  display: grid;
  min-height: 100vh;
  grid-template-columns: minmax(0, 1fr);
  grid-template-areas:
    "header"
    "nav"
    "main"
    "aside"
    "footer";
  gap: var(--space-2);
  padding: var(--space-2);
}
.site-header { grid-area: header; }
.site-nav { grid-area: nav; }
.main-content { grid-area: main; }
.sidebar { grid-area: aside; }
.site-footer { grid-area: footer; }
/* Regions: shared looks */
.site-header, .site-nav, .main-content, .sidebar, .site-footer {
  background: var(--main-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-3);
}
.site-header { background: var(--header-bg); color: var(--header-text); }
.site-header p { color: #c8d1d6; margin: 0; }
/* Navigation: collapsible with checkbox */
.site-nav { background: var(--nav-bg); }
.menu-toggle, .menu-box { display: none; }
.menu-label { display: inline-block; cursor: pointer; padding: var(--space-1) var(--space-2); border: 1px solid var(--border); border-radius: var(--radius); background: var(--main-bg); font-size: 1rem; }
.menu-box:checked ~ .menu-list { display: flex; }
.menu-list { list-style: none; margin: var(--space-2) 0 0; padding: 0; display: none; flex-direction: column; gap: var(--space-1); }
.menu-list a { display: block; padding: var(--space-1) var(--space-2); text-decoration: none; color: var(--text); border-radius: var(--radius); }
.menu-list a:hover { background: var(--main-bg); }
/* Main: post cards */
.post-list { display: grid; grid-template-columns: 1fr; gap: var(--space-2); }
.post-card { background: var(--main-bg); border: 1px solid var(--border); border-radius: var(--radius); padding: var(--space-2); }
.card-image { background: var(--card-bg); aspect-ratio: 16 / 9; border-radius: var(--radius); margin-bottom: var(--space-2); }
.post-card time { color: var(--muted); font-size: 0.875rem; }
/* Sidebar: categories and recent posts */
.sidebar { background: var(--aside-bg); }
.sidebar h2 { font-size: 1.125rem; }
.sidebar ul { list-style: none; margin: 0 0 var(--space-3); padding: 0; }
.sidebar a { color: var(--text); }
/* Footer */
.site-footer { background: var(--footer-bg); color: var(--muted); }
/* Breakpoint 1: 640px, two-column post cards */
@media (min-width: 640px) {
  .post-list { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
  .menu-list { display: flex; flex-direction: row; }
  .menu-list li { margin-right: var(--space-2); }
  .menu-label { display: none; }
}
/* Breakpoint 2: 1024px, sidebar beside main via grid areas */
@media (min-width: 1024px) {
  .page {
    grid-template-columns: minmax(0, 2fr) minmax(15rem, 1fr);
    grid-template-areas:
      "header header"
      "nav nav"
      "main aside"
      "footer footer";
  }
}
/* Breakpoint 3: 1280px, wider columns and sticky sidebar */
@media (min-width: 1280px) {
  .page { max-width: 1200px; margin: 0 auto; grid-template-columns: minmax(0, 2.5fr) minmax(18rem, 1fr); gap: var(--space-3); }
  .sidebar { position: sticky; top: var(--space-3); align-self: start; }
}
</style>
</head>
<body>
<a class="skip-link" href="#main-content">Skip to content</a>
<div class="page">
  <header class="site-header">
    <h1>Blog title</h1>
    <p>A short tagline for the blog goes here.</p>
  </header>
  <nav class="site-nav" aria-label="Main navigation">
    <input class="menu-toggle" id="menu" type="checkbox" class="menu-box">
    <label class="menu-label menu-toggle" for="menu">Menu</label>
    <ul class="menu-list">
      <li><a href="#">Home</a></li>
      <li><a href="#">Posts</a></li>
      <li><a href="#">About</a></li>
      <li><a href="#">Contact</a></li>
    </ul>
  </nav>
  <main id="main-content" class="main-content">
    <section aria-label="Recent posts">
      <article class="post-card">
        <div class="card-image" role="img" aria-label="Post image placeholder"></div>
        <h2>Post heading one</h2>
        <p>Short excerpt of the post that visitors can replace with real content.</p>
        <time datetime="2024-01-01">1 January</time>
      </article>
      <article class="post-card">
        <div class="card-image" role="img" aria-label="Post image placeholder"></div>
        <h2>Post heading two</h2>
        <p>Short excerpt of the post that visitors can replace with real content.</p>
        <time datetime="2024-01-02">2 January</time>
      </article>
      <article class="post-card">
        <div class="card-image" role="img" aria-label="Post image placeholder"></div>
        <h2>Post heading three</h2>
        <p>Short excerpt of the post that visitors can replace with real content.</p>
        <time datetime="2024-01-03">3 January</time>
      </article>
    </section>
  </main>
  <aside class="sidebar" aria-label="Blog sidebar">
    <section>
      <h2>Categories</h2>
      <ul>
        <li><a href="#">Category one</a></li>
        <li><a href="#">Category two</a></li>
        <li><a href="#">Category three</a></li>
      </ul>
    </section>
    <section>
      <h2>Recent posts</h2>
      <ul>
        <li><a href="#">Recent post one</a></li>
        <li><a href="#">Recent post two</a></li>
        <li><a href="#">Recent post three</a></li>
      </ul>
    </section>
  </aside>
  <footer class="site-footer">
    <p>Footer text with contact or legal links goes here.</p>
  </footer>
</div>
</body>
</html>

Dashboard layout with collapsible navigation

A dashboard layout with a top bar, a collapsible side navigation, four stat cards and a main panel for a chart and a table

Grid + Flexbox Hybrid · Desktop First · 189 lines
<!doctype html>
<!-- Dashboard layout: Grid page regions, Flexbox inside them -->
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Dashboard Layout</title>
<style>
/* Variables: colours and spacing */
:root {
  --bg: #f4f6fb;
  --panel: #ffffff;
  --topbar: #1f2a44;
  --sidebar: #e8ecf7;
  --card: #eef4ff;
  --accent: #3457d5;
  --text: #1d2433;
  --muted: #5a6478;
  --border: #d5dbe8;
  --space: 1rem;
  --radius: 0.5rem;
}
/* Base: reset and typography */
*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; font-family: system-ui, sans-serif; background: var(--bg); color: var(--text); font-size: 1rem; line-height: 1.5; }
a { color: var(--accent); }
a:focus-visible, button:focus-visible, summary:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.skip-link { position: absolute; left: -999px; background: var(--accent); color: #fff; padding: 0.5rem 1rem; }
.skip-link:focus { left: 0.5rem; top: 0.5rem; z-index: 10; }
h1, h2, h3 { margin: 0 0 0.5rem; }
p { margin: 0 0 0.75rem; }
/* Layout: Grid for page regions (desktop base) */
.page {
  display: grid;
  min-height: 100vh;
  grid-template-columns: 15rem 1fr;
  grid-template-rows: auto 1fr auto;
  grid-template-areas:
    "topbar topbar"
    "sidebar main"
    "footer footer";
}
/* Top bar: Flexbox row for brand and toolbar */
.site-header {
  grid-area: topbar;
  background: var(--topbar);
  color: #fff;
  display: flex;
  align-items: center;
  gap: var(--space);
  padding: 0.75rem 1rem;
}
.brand { font-weight: 700; margin: 0; }
.toolbar { margin-left: auto; display: flex; gap: 0.5rem; flex-wrap: wrap; }
.toolbar a { color: #fff; text-decoration: none; padding: 0.25rem 0.75rem; border-radius: var(--radius); }
.toolbar a:hover { background: rgba(255, 255, 255, 0.15); }
/* Sidebar: collapsible nav via details/summary (keyboard friendly) */
.sidebar { grid-area: sidebar; background: var(--sidebar); padding: var(--space); border-right: 1px solid var(--border); }
.sidebar summary { cursor: pointer; font-weight: 700; padding: 0.25rem 0; }
.sidebar nav ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.25rem; }
.sidebar nav a { display: block; text-decoration: none; padding: 0.5rem 0.75rem; border-radius: var(--radius); color: var(--text); }
.sidebar nav a:hover { background: #d8e0f2; }
/* Main: stat cards grid plus chart and table panels */
.main { grid-area: main; padding: var(--space); display: flex; flex-direction: column; gap: var(--space); }
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--space); }
.stat-card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: var(--space); display: flex; flex-direction: column; gap: 0.25rem; }
.stat-card .value { font-size: 1.75rem; font-weight: 700; }
.stat-card .label { color: var(--muted); font-size: 0.875rem; }
.panel { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: var(--space); }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: var(--space); flex-wrap: wrap; }
.chart { background: linear-gradient(180deg, #dfe8ff, #f0f4ff); border-radius: var(--radius); aspect-ratio: 16 / 6; margin-top: var(--space); }
@supports not (aspect-ratio: 1) { .chart { min-height: 12rem; } }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; margin-top: var(--space); }
th, td { text-align: left; padding: 0.5rem 0.75rem; border-bottom: 1px solid var(--border); }
th { color: var(--muted); font-size: 0.875rem; }
.actions { display: flex; gap: 0.5rem; }
.actions button { background: var(--accent); color: #fff; border: 0; border-radius: var(--radius); padding: 0.4rem 0.9rem; font-size: 0.875rem; cursor: pointer; }
/* Footer */
.site-footer { grid-area: footer; background: var(--panel); border-top: 1px solid var(--border); padding: 0.75rem 1rem; color: var(--muted); }
/* Breakpoint 1: 1279px - drop to 2 stat columns */
@media (max-width: 1279px) {
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
}
/* Breakpoint 2: 1023px - sidebar above main, full width */
@media (max-width: 1023px) {
  .page {
    grid-template-columns: 1fr;
    grid-template-areas:
      "topbar"
      "sidebar"
      "main"
      "footer";
  }
  .sidebar { border-right: 0; border-bottom: 1px solid var(--border); }
}
/* Breakpoint 3: 639px - single column, stacked cards */
@media (max-width: 639px) {
  .stat-grid { grid-template-columns: 1fr; }
  .site-header { flex-wrap: wrap; }
  .toolbar { margin-left: 0; }
}
</style>
</head>
<body>
<a class="skip-link" href="#main-content">Skip to content</a>
<div class="page">
  <!-- Top bar: Flexbox because it is a single-direction row -->
  <header class="site-header">
    <p class="brand">Dashboard Name</p>
    <nav class="toolbar" aria-label="Quick actions">
      <a href="#">Search</a>
      <a href="#">Alerts</a>
      <a href="#">Account</a>
    </nav>
  </header>
  <!-- Sidebar: details toggles the nav with CSS only -->
  <aside class="sidebar">
    <details open>
      <summary>Menu</summary>
      <nav aria-label="Main navigation">
        <ul>
          <li><a href="#">Overview</a></li>
          <li><a href="#">Reports</a></li>
          <li><a href="#">Projects</a></li>
          <li><a href="#">Team</a></li>
          <li><a href="#">Settings</a></li>
        </ul>
      </nav>
    </details>
  </aside>
  <!-- Main: Grid for stat cards, Flexbox for panel heads and buttons -->
  <main class="main" id="main-content">
    <section class="stat-grid" aria-label="Key statistics">
      <article class="stat-card">
        <h3 class="label">Visitors</h3>
        <p class="value">1,234</p>
      </article>
      <article class="stat-card">
        <h3 class="label">Orders</h3>
        <p class="value">567</p>
      </article>
      <article class="stat-card">
        <h3 class="label">Revenue</h3>
        <p class="value">$8,900</p>
      </article>
      <article class="stat-card">
        <h3 class="label">Open tasks</h3>
        <p class="value">42</p>
      </article>
    </section>
    <section class="panel" aria-label="Chart panel">
      <div class="panel-head">
        <h2>Activity chart</h2>
        <div class="actions">
          <button type="button">Week</button>
          <button type="button">Month</button>
        </div>
      </div>
      <p>Replace this block with your chart.</p>
      <div class="chart" role="img" aria-label="Placeholder chart area"></div>
    </section>
    <section class="panel" aria-label="Data table panel">
      <div class="panel-head">
        <h2>Recent items</h2>
        <div class="actions">
          <button type="button">View all</button>
        </div>
      </div>
      <div class="table-wrap">
        <table>
          <thead>
            <tr><th scope="col">Name</th><th scope="col">Status</th><th scope="col">Amount</th></tr>
          </thead>
          <tbody>
            <tr><td>Item one</td><td>Active</td><td>$120</td></tr>
            <tr><td>Item two</td><td>Pending</td><td>$340</td></tr>
            <tr><td>Item three</td><td>Active</td><td>$90</td></tr>
          </tbody>
        </table>
      </div>
    </section>
  </main>
  <footer class="site-footer">
    <p>Short footer text goes here.</p>
  </footer>
</div>
</body>
</html>

Masonry grid for image gallery

A masonry grid for an image gallery with a title bar and twelve images of different heights

CSS Grid · Custom · 139 lines
<!doctype html>
<!-- Masonry image gallery: title bar, collapsible nav, 12 varied-height images, CSS Grid, mobile first (480, 640, 768, 1024, 1280px) -->
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Masonry Gallery Layout</title>
<style>
/* Variables: colours and spacing */
:root {
  --colour-bg: #f4f1ec;
  --colour-header: #2c3e50;
  --colour-nav: #34495e;
  --colour-aside: #e8eef1;
  --colour-card: #d8cfc4;
  --colour-card-alt: #cbbfae;
  --colour-text: #2b2b2b;
  --colour-light: #ffffff;
  --space: 1rem;
  --space-lg: 2rem;
}
/* Base: reset and typography */
*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; font-family: system-ui, sans-serif; color: var(--colour-text); background: var(--colour-bg); font-size: 1rem; line-height: 1.5; }
.skip-link { position: absolute; left: -9999px; top: 0; background: var(--colour-header); color: var(--colour-light); padding: 0.5rem 1rem; }
.skip-link:focus-visible, a:focus-visible, button:focus-visible, .nav-toggle:focus-visible { outline: 3px solid #e67e22; outline-offset: 2px; position: relative; }
.skip-link:focus-visible { left: 0; }
a { color: inherit; }
/* Layout: page grid with named areas */
.page-wrapper { display: grid; grid-template-areas: "header" "nav" "main" "aside" "footer"; min-height: 100vh; }
.site-header { grid-area: header; }
.site-nav { grid-area: nav; }
.main-content { grid-area: main; }
.sidebar { grid-area: aside; }
.site-footer { grid-area: footer; }
/* Regions: header, nav, aside, footer */
.site-header { background: var(--colour-header); color: var(--colour-light); padding: var(--space-lg); text-align: center; }
.site-header h1 { margin: 0; font-size: 1.75rem; }
.site-header p { margin: 0.5rem 0 0; font-size: 1rem; }
.site-nav { background: var(--colour-nav); padding: var(--space); }
.site-nav ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.5rem; }
.site-nav a { color: var(--colour-light); text-decoration: none; padding: 0.4rem 0.75rem; display: block; border-radius: 0.25rem; }
.site-nav a:hover { background: rgba(255, 255, 255, 0.15); }
.nav-toggle { display: block; color: var(--colour-light); font-size: 1rem; cursor: pointer; padding: 0.4rem 0.75rem; background: none; border: 1px solid rgba(255,255,255,0.4); border-radius: 0.25rem; width: 100%; }
.nav-menu { display: none; }
.nav-toggle[aria-expanded="true"] + .nav-menu,
.nav-menu.open { display: flex; }
.main-content { padding: var(--space-lg); }
.sidebar { background: var(--colour-aside); padding: var(--space-lg); border-top: 1px solid #c5d2d9; }
.sidebar h2 { margin-top: 0; font-size: 1.25rem; }
.site-footer { background: var(--colour-header); color: var(--colour-light); padding: var(--space); text-align: center; font-size: 0.875rem; }
/* Gallery: masonry via row spans, dense fill */
.card-grid { display: grid; grid-template-columns: 1fr; grid-auto-rows: 8rem; grid-auto-flow: dense; gap: var(--space); }
.card-grid .card { overflow: hidden; }
.card { background: var(--colour-card); border-radius: 0.5rem; display: grid; grid-template-rows: 1fr auto; }
.card .image { width: 100%; background: var(--colour-card-alt); }
.card figcaption, .card p { margin: 0; padding: 0.5rem 0.75rem; font-size: 0.875rem; }
.span-3 .image { aspect-ratio: 3 / 2; } .span-4 .image { aspect-ratio: 4 / 3; } .span-5 .image { aspect-ratio: 1 / 1; } .span-6 .image { aspect-ratio: 3 / 4; }
.span-3 { grid-row: span 3; } .span-4 { grid-row: span 4; } .span-5 { grid-row: span 5; } .span-6 { grid-row: span 6; }
@supports (aspect-ratio: 1) { .card .image { aspect-ratio: 1 / 1; } }
/* 480px: two-column gallery, nav row */
@media (min-width: 480px) {
  .card-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .site-nav ul { flex-direction: row; flex-wrap: wrap; }
  .nav-toggle { width: auto; }
}
/* 640px: aside becomes two-column info block */
@media (min-width: 640px) {
  .sidebar { display: grid; grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr)); gap: var(--space-lg); }
}
/* 768px: aside moves beside main */
@media (min-width: 768px) {
  .page-wrapper { grid-template-areas: "header header" "nav nav" "main aside" "footer footer"; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
  .card-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
/* 1024px: four-column gallery, wider nav */
@media (min-width: 1024px) {
  .card-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); grid-auto-rows: 7rem; }
  .main-content { padding: var(--space-lg) var(--space); }
}
/* 1280px: five-column gallery, wider main column */
@media (min-width: 1280px) {
  .page-wrapper { grid-template-columns: minmax(0, 3fr) minmax(0, 1fr); }
  .card-grid { grid-template-columns: repeat(5, minmax(0, 1fr)); }
}
</style>
</head>
<body>
<a class="skip-link" href="#main">Skip to content</a>
<div class="page-wrapper">
  <header class="site-header">
    <h1>Gallery Title Bar</h1>
    <p>A short line describing this image collection.</p>
  </header>
  <nav class="site-nav" aria-label="Main navigation">
    <button class="nav-toggle" aria-expanded="false" aria-controls="nav-menu">Menu ▾</button>
    <details class="nav-menu" id="nav-menu">
      <summary style="list-style:none; color: var(--colour-light); padding: 0.4rem 0.75rem;">Browse</summary>
      <ul>
        <li><a href="#">All images</a></li>
        <li><a href="#">Collections</a></li>
        <li><a href="#">Popular</a></li>
        <li><a href="#">About</a></li>
      </ul>
    </details>
  </nav>
  <main class="main-content" id="main">
    <h2>Latest images</h2>
    <div class="card-grid">
      <figure class="card span-4"><div class="image"></div><figcaption>Placeholder caption one</figcaption></figure>
      <figure class="card span-6"><div class="image"></div><figcaption>Placeholder caption two</figcaption></figure>
      <figure class="card span-3"><div class="image"></div><figcaption>Placeholder caption three</figcaption></figure>
      <figure class="card span-5"><div class="image"></div><figcaption>Placeholder caption four</figcaption></figure>
      <figure class="card span-4"><div class="image"></div><figcaption>Placeholder caption five</figcaption></figure>
      <figure class="card span-6"><div class="image"></div><figcaption>Placeholder caption six</figcaption></figure>
      <figure class="card span-3"><div class="image"></div><figcaption>Placeholder caption seven</figcaption></figure>
      <figure class="card span-5"><div class="image"></div><figcaption>Placeholder caption eight</figcaption></figure>
      <figure class="card span-4"><div class="image"></div><figcaption>Placeholder caption nine</figcaption></figure>
      <figure class="card span-6"><div class="image"></div><figcaption>Placeholder caption ten</figcaption></figure>
      <figure class="card span-3"><div class="image"></div><figcaption>Placeholder caption eleven</figcaption></figure>
      <figure class="card span-5"><div class="image"></div><figcaption>Placeholder caption twelve</figcaption></figure>
    </div>
  </main>
  <aside class="sidebar">
    <section>
      <h2>About</h2>
      <p>Short sidebar text the visitor replaces with real content.</p>
    </section>
    <section>
      <h2>Tags</h2>
      <p>A few placeholder tags or category links.</p>
    </section>
  </aside>
  <footer class="site-footer">
    <p>Footer text — replace with your own notice or links.</p>
  </footer>
</div>
</body>
</html>

Holy grail layout with header, footer, and columns

A holy grail layout with a header, a footer, a left navigation, the main content and a right sidebar

Flexbox · Mobile First · 139 lines
<!doctype html>
<!-- Holy grail layout: header, footer, left nav, main content, right sidebar (Flexbox, mobile first) -->
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Holy Grail Flexbox Layout</title>
<style>
/* Variables: colours and spacing */
:root {
  --bg-page: #f4f5f7;
  --bg-header: #2f3e50;
  --bg-nav: #e2e8f0;
  --bg-main: #ffffff;
  --bg-aside: #fdf1e0;
  --bg-footer: #2f3e50;
  --bg-card: #eef2f7;
  --text: #2b2b2b;
  --text-light: #f4f5f7;
  --accent: #3b6ea5;
  --space: 1rem;
  --radius: 0.5rem;
}

/* Base: reset and typography */
*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; font-family: system-ui, sans-serif; font-size: 1rem; line-height: 1.6; color: var(--text); background: var(--bg-page); }
h1, h2, h3 { line-height: 1.25; margin: 0 0 var(--space); }
p { margin: 0 0 var(--space); }
a { color: var(--accent); }

/* Accessibility: skip link and focus style */
.skip-link { position: absolute; left: -999px; top: 0; background: var(--accent); color: var(--text-light); padding: 0.5rem 1rem; z-index: 10; }
.skip-link:focus { left: 0; }
a:focus-visible, button:focus-visible, summary:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

/* Layout shell: page is one flex column on phones */
.page { display: flex; flex-direction: column; min-height: 100vh; }
.body-area { display: flex; flex-direction: column; flex: 1 1 auto; gap: var(--space); padding: var(--space); }

/* Regions: header, nav, main, sidebar, footer */
.site-header { background: var(--bg-header); color: var(--text-light); padding: var(--space); display: flex; flex-direction: column; gap: 0.5rem; align-items: flex-start; }
.site-header p { margin: 0; }

.main-nav { background: var(--bg-nav); border-radius: var(--radius); padding: var(--space); }
.main-nav summary { cursor: pointer; font-weight: bold; }
.main-nav ul { list-style: none; margin: var(--space) 0 0; padding: 0; display: flex; flex-direction: column; gap: 0.5rem; }
.main-nav a { display: block; padding: 0.5rem; border-radius: var(--radius); background: var(--bg-main); text-decoration: none; }
.main-nav a:hover { background: var(--accent); color: var(--text-light); }

.main-content { flex: 1 1 auto; background: var(--bg-main); border-radius: var(--radius); padding: var(--space); display: flex; flex-direction: column; gap: var(--space); }
.card-grid { display: flex; flex-direction: column; gap: var(--space); }
.card { background: var(--bg-card); border-radius: var(--radius); padding: var(--space); }
.card .image { background: #d8e0ea; aspect-ratio: 16 / 9; border-radius: var(--radius); margin-bottom: var(--space); }

.sidebar { flex: 1 1 auto; background: var(--bg-aside); border-radius: var(--radius); padding: var(--space); display: flex; flex-direction: column; gap: var(--space); }

.site-footer { background: var(--bg-footer); color: var(--text-light); padding: var(--space); display: flex; flex-direction: column; gap: 0.5rem; align-items: flex-start; }

/* Breakpoint 1: 640px, nav links in a row, cards side by side */
@media (min-width: 640px) {
  .site-header { flex-direction: row; justify-content: space-between; align-items: center; }
  .main-nav ul { flex-direction: row; flex-wrap: wrap; }
  .card-grid { flex-direction: row; flex-wrap: wrap; }
  .card { flex: 1 1 15rem; }
}

/* Breakpoint 2: 1024px, sidebar moves beside main content */
@media (min-width: 1024px) {
  .body-area { flex-direction: row; }
  .main-nav { flex: 0 0 12rem; }
  .main-content { flex: 1 1 60%; }
  .sidebar { flex: 0 0 14rem; }
}

/* Breakpoint 3: 1280px, wider nav and sidebar, more breathing room */
@media (min-width: 1280px) {
  :root { --space: 1.5rem; }
  .main-nav { flex-basis: 14rem; }
  .sidebar { flex-basis: 16rem; }
  .card { flex: 1 1 18rem; }
}
</style>
</head>
<body>
<a class="skip-link" href="#main-content">Skip to content</a>
<div class="page">

  <header class="site-header">
    <h1>Site Name</h1>
    <p>Short tagline goes here</p>
  </header>

  <div class="body-area">

    <nav class="main-nav" aria-label="Main navigation">
      <details>
        <summary>Menu</summary>
        <ul>
          <li><a href="#">Home</a></li>
          <li><a href="#">Topics</a></li>
          <li><a href="#">Archive</a></li>
          <li><a href="#">Contact</a></li>
        </ul>
      </details>
    </nav>

    <main class="main-content" id="main-content">
      <h2>Main Content</h2>
      <p>Replace this with your page introduction and body copy.</p>
      <div class="card-grid">
        <article class="card">
          <div class="image"></div>
          <h3>Card One</h3>
          <p>Short placeholder text for the first card.</p>
        </article>
        <article class="card">
          <div class="image"></div>
          <h3>Card Two</h3>
          <p>Short placeholder text for the second card.</p>
        </article>
      </div>
    </main>

    <aside class="sidebar">
      <h2>Sidebar</h2>
      <p>Related links, tips or extras go here.</p>
      <p>Another short placeholder paragraph.</p>
    </aside>

  </div>

  <footer class="site-footer">
    <p>Footer text and links go here.</p>
  </footer>

</div>
</body>
</html>

Features of Every Layout from Our AI Layout Generator

Every layout from AIFreeForever's AI Layout Generator comes with semantic HTML5 regions, responsive breakpoints and a live preview button.

Semantic HTML5 Regions

Header, nav, main, aside and footer tags give every region a clear meaning.

Responsive Breakpoints

Mobile first, desktop first or five custom breakpoints control how columns change.

Live Preview

The Preview button draws the finished page in a safe frame before you copy.

Custom Properties

Colours and spacing sit in CSS custom properties, so you can restyle them in one place.

Accessible Structure

A skip to content link and visible focus styles help keyboard and screen reader users.

Collapsible Parts

A collapsible navigation or section works with HTML and CSS only.

Frequently Asked Questions

Why Choose AIFreeForever's AI Layout Generator?

Starting a new page from a working layout is simple with AIFreeForever's AI Layout Generator.

Free to Use

Generate responsive layouts for free on AIFreeForever.

Four Layout Techniques

Pick the method that fits a modern site or an old codebase.

Three Breakpoint Strategies

Get a layout that works on phones, tablets and desktop screens.

Placeholder Content

Every region ships with short sample text you can replace quickly.

Download layout.html

Save one whole HTML page with all the CSS inside.

Chat Changes

Ask in the chat box to make the sidebar sticky or add a card grid.

Generate a Page Layout for Free

Pick your layout technique and breakpoints, describe the page you need, and get its HTML and CSS from AIFreeForever's AI Layout Generator.

Page layout planning from the free AI Layout Generator: a designer arranging wireframe sketches at a desk

Related Developer Tools

By the AIFreeForever Research Team Last updated