CSS Layout Generator

Choose a preset, adjust sections and spacing, and preview your responsive Grid or Flexbox layout instantly.

Layout engine

Grid is ideal for page structure; Flexbox is useful for simpler shells.

StructureChoose sections and dimensions
Spacing & sizingControl the outer shell and gaps
AppearanceSet section colors and surface details
Responsive & outputMobile behavior and code preferences

Preview your responsive layout

Compare desktop, tablet and mobile layouts before exporting your HTML and CSS.

your-layout.test Desktop · responsive
Header
Main content
Footer

Export HTML and CSS

Copy your code, download a standalone HTML page, or get a ZIP with HTML, CSS and a README.

Free CSS layout generator for responsive Grid and Flexbox pages

Build a responsive page structure with Toolslight’s CSS Layout Generator. Choose one of six presets, adjust the header, navigation, sidebars and content area, then preview the layout on desktop, tablet and mobile. Copy editable HTML and CSS, download a standalone page, or export a project ZIP.

Developers can use the output as a starting shell for a website or application. Designers can compare page structures before adding finished content, and students can inspect how changing a layout setting changes its CSS. The exported structure uses native CSS without requiring Bootstrap, Tailwind or a JavaScript layout library.

This builder focuses on page regions: headers, navigation, main content, sidebars and footers. Use the Grid engine for track-based page structure or the Flexbox engine for a flexible shell. Both modes produce a single-column content row at your chosen mobile breakpoint.

Generate a responsive HTML and CSS layout

  1. Choose a preset: Classic, Holy Grail, Dashboard, Blog, Landing Page or App Shell.
  2. Choose the layout engine: CSS Grid or Flexbox. Inspect the CSS tab to compare their output.
  3. Adjust the structure: enable the regions you need, set sidebar widths and choose the container width, gaps and padding.
  4. Set mobile behavior: under Responsive & output, choose the breakpoint, whether each sidebar stacks or hides, and the visual order of the content.
  5. Preview and export: compare Desktop, Tablet and Mobile, then copy the HTML/CSS or download your files. Open the exported page and test it with real content before using it in a project.

Six layout patterns to try in the generator

The dimensions below are preset starting values. You can change them in the controls. Header, navigation and footer height settings generate minimum heights, allowing their content to grow.

Classic: a responsive two-column layout

Choose Classic for a header, left sidebar, main area and footer. Its default Grid content row uses a 220px sidebar beside minmax(0, 1fr), which takes the remaining space. The page is centered with a 1200px maximum width and a 16px gap.

Try it: change the left sidebar width, then switch to Mobile. Choose Stack to place the sidebar in the content sequence, or Hide only when its content is available through another suitable route. This is a useful starting point for documentation or a small website with supporting navigation.

Holy Grail: a three-column layout with two sidebars

Choose Holy Grail for a header, navigation, left sidebar, flexible main column, right sidebar and footer. The default content tracks are 190px minmax(0, 1fr) 230px, with a 14px gap and a 1280px maximum page width.

Try it: leave both sidebars set to Stack and select Main content first. At the mobile breakpoint, the visual sequence becomes main content, left sidebar and right sidebar. The HTML reading order remains unchanged; review the accessibility guidance below before adding interactive content.

Dashboard: a workspace with a sticky sidebar

Choose Dashboard for a Grid-based application workspace with a 250px left sidebar, a flexible main area and a header. The default shell has no maximum-width cap, no footer and a 12px gap.

The sidebar uses position: sticky, an offset from the top and align-self: start. It remains part of the layout and sticks within its scrolling context; it is not a position: fixed overlay. Try it: toggle Sticky sidebars, export the page and add enough content to test scrolling. The mobile rules return the sidebar to normal positioning.

Blog: an article with a right sidebar

Choose Blog for a header, navigation, article area, right sidebar and footer. The default Grid content row is minmax(0, 1fr) 300px, with a 24px gap and a centered 1100px maximum-width shell.

Try it: keep related links in the right sidebar and compare Stack and Hide on mobile. Let the main article grow naturally, and test long titles, images and code blocks. The preset defines the page structure; add your own article typography and reading-width rules.

Landing Page: a single-column shell

Choose Landing Page for a header, main region and footer with no sidebars. Its default engine is Flexbox: the outer shell uses flex-direction: column, and the content row can grow. The preset starts with zero outer padding and gap, while retaining a 1200px maximum-width cap.

Try it: add your hero and page sections inside the main region. Set Container width to full width if you need an uncapped shell. A landing-page preset supplies the layout structure; your copy, images and components complete the page.

App Shell: an edge-to-edge application layout

Choose App Shell for a Flexbox-based header, a 240px left sidebar and a flexible main area. It starts without a footer, width cap, outer padding or gap. The sidebar uses flex: 0 0 240px, while the main region uses flex: 1 1 0.

Try it: add application navigation to the sidebar and compare its mobile stacking options. Compared with Dashboard, this preset starts with a different engine and tighter spacing. Routing, menus, authentication and application behavior belong to your project and are not included in the layout export.

CSS Grid vs. Flexbox: a developer reference

Choose Grid when rows and columns need a shared track structure. Choose Flexbox when arranging and distributing items along one main axis. You can combine them, such as Grid for the page shell and Flexbox for a toolbar inside the main region.

Question or property CSS Grid Flexbox
Dimensions Two-dimensional: shared rows and columns One-dimensional: a main axis; wrapped lines are laid out independently
Typical starting point Layout-first: define tracks and place content in them Content-first: let items and available space drive distribution
Basic declaration display: grid display: flex
Main sizing controls grid-template-columns, grid-template-rows, minmax(), fr flex-direction, flex-basis, flex-grow, flex-shrink
Example sidebar and content grid-template-columns: 220px minmax(0, 1fr) Sidebar: flex: 0 0 220px; main: flex: 1 1 0
Item alignment justify-items aligns within cells on the inline axis; align-items on the block axis justify-content distributes along the main axis; align-items aligns across it
Group alignment justify-content and align-content position the grid tracks when free space allows align-content distributes lines in a wrapping container when cross-axis space is available
Individual overrides justify-self, align-self align-self; justify-self does not align flex items
Spacing gap, row-gap, column-gap gap, row-gap, column-gap
Placement and ordering Named areas, grid lines or auto-placement; order can affect auto-placement Source order plus optional order; flex-wrap allows wrapping
Browser support Core Grid features work in current Chrome, Edge, Firefox and Safari Core Flexbox and flex gaps work in current Chrome, Edge, Firefox and Safari

These are useful starting distinctions, not restrictions: Grid can size tracks from content, and Flexbox can use explicit sizes. Check support for the particular properties in your exported CSS if you must support older browsers. Selecting Flexbox here does not remove the mobile Grid rules.

Worked example: responsive Holy Grail CSS

Select Holy Grail, keep the CSS Grid engine, set the breakpoint to 768px, leave both sidebars on Stack, and choose Main content first. With the default class prefix, the content row has the following simplified markup. The header, navigation and footer sit outside this inner row.

<div class="page-layout__body">
  <aside class="page-layout__sidebar page-layout__sidebar--left">
    Left sidebar content
  </aside>
  <main class="page-layout__main">
    Main page content
  </main>
  <aside class="page-layout__sidebar page-layout__sidebar--right">
    Related content
  </aside>
</div>

This reduced excerpt shows the relevant generated rules. The complete export also includes the outer shell, spacing, minimum heights and appearance styles.

.page-layout {
  --left-width: 190px;
  --right-width: 230px;
  --layout-gap: 14px;
}

.page-layout__body {
  display: grid;
  grid-template-columns:
    var(--left-width) minmax(0, 1fr) var(--right-width);
  gap: var(--layout-gap);
  min-width: 0;
}

.page-layout__main,
.page-layout__sidebar {
  min-width: 0;
}

@media (max-width: 768px) {
  .page-layout__body {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
  }

  .page-layout__main { order: 1; }
  .page-layout__sidebar--left { order: 2; }
  .page-layout__sidebar--right { order: 3; }
}

The fixed sidebars keep their configured desktop track widths. The center track takes the remaining available space after those tracks and gaps. minmax(0, 1fr) allows that track to shrink below its content’s automatic minimum; min-width: 0 allows the child region to shrink as well. Long content still needs an appropriate wrapping or scrolling rule.

At 768px and below, the row becomes a single column. order works on Grid items as well as Flexbox items, so it determines the visual sequence of these auto-placed regions. It does not move the HTML nodes or change their normal keyboard sequence.

If you choose Hide for a sidebar, the generator adds display: none for that sidebar inside the media query. When sticky sidebars are enabled, the mobile rules also set their position back to static.

The Desktop, Tablet and Mobile controls represent nominal widths of 1280px, 820px and 390px. With a 768px breakpoint, Tablet stays in the wide layout. The export has one adjustable breakpoint, so also test the downloaded page just above and below that boundary.

How the Flexbox desktop version differs

Switching to Flexbox replaces the desktop content-row sizing with the following approach. These base rules belong before the mobile media query in the stylesheet; the mobile content row still becomes Grid.

.page-layout__body {
  display: flex;
  gap: var(--layout-gap);
  min-width: 0;
  flex: 1 1 auto;
}

.page-layout__sidebar--left {
  flex: 0 0 var(--left-width);
}

.page-layout__main {
  flex: 1 1 0;
  min-width: 0;
}

.page-layout__sidebar--right {
  flex: 0 0 var(--right-width);
}

In flex: 0 0 190px, the numbers mean no growth, no shrinkage and a 190px starting basis. In flex: 1 1 0, the main region can grow and shrink from a zero basis. Inspect the complete export when switching engines so that obsolete Grid declarations are removed with the original desktop block.

Optional adaptation: use grid-template-areas

Named areas make a region-based layout easy to read. The current generator does not emit grid-template-areas; this is an alternative you can write after export. For the three-region row above, replace its desktop placement and mobile ordering rules with this version. Keep both sidebars present and set to Stack.

.page-layout__body {
  display: grid;
  grid-template-columns:
    var(--left-width) minmax(0, 1fr) var(--right-width);
  grid-template-areas: "left main right";
  gap: var(--layout-gap);
  min-width: 0;
}

.page-layout__sidebar--left {
  grid-area: left;
  order: 0;
}

.page-layout__main {
  grid-area: main;
  order: 0;
}

.page-layout__sidebar--right {
  grid-area: right;
  order: 0;
}

@media (max-width: 768px) {
  .page-layout__body {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas:
      "main"
      "left"
      "right";
  }
}

Each string describes one grid row. If an area spans several cells, those cells must form a rectangle, and every row must have the same number of cells. Assign the matching name with grid-area. Changing the map changes visual placement, so named areas need the same source-order review as order.

Prevent overflow in real page content

Flexible tracks do not make every image, table or long URL fit automatically. Start with min-width: 0 on shrinking regions, then handle each content type deliberately. These are optional additions for your project, rather than rules currently emitted by the generator:

.page-layout__main img {
  max-width: 100%;
  height: auto;
}

.page-layout__main p,
.page-layout__main a {
  overflow-wrap: anywhere;
}

.page-layout__main pre,
.page-layout__main .table-scroll {
  max-width: 100%;
  overflow-x: auto;
}

Wrap a wide table in an element with the table-scroll class when horizontal scrolling is appropriate. If your fixed sidebars leave too little room for the main column above 768px, raise the breakpoint or reduce the sidebar widths. Do not hide the entire page’s horizontal overflow to conceal clipped content.

Export and integrate the layout

Output What you receive Best use
HTML and CSS code tabs Layout markup and its layout stylesheet Integrating with an existing site
All code / Standalone HTML A complete HTML document with embedded CSS Opening and editing a prototype locally
Complete ZIP index.html, styles.css and README.txt Starting a separate project
HTML only and CSS only downloads A complete HTML document linked to styles.css, and a stylesheet including page-level defaults Separate files for a standalone page

Choose a class prefix appropriate to your project and check for existing stylesheet conflicts. Standalone files and downloaded styles include rules for html and body; review those before merging them into an established site. A prefix helps separate class selectors, but it is not complete CSS isolation.

In React, convert the markup to JSX, including class to className, then load the stylesheet. In WordPress, place the appropriate regions in your theme or component structure and enqueue the styles. Check the page’s existing landmarks and heading hierarchy before adding another header or main region.

The export is vanilla HTML/CSS. You can integrate it into a Bootstrap or Tailwind project, but it does not generate those frameworks’ utility classes. The online builder uses JavaScript; the exported layout does not need JavaScript to size, align or stack its regions.

Accessibility and final layout checks

  • Use meaningful landmarks. Keep one visible <main> for the page’s primary content. Use <nav> for navigation and <aside> for supporting content. Page-level <header> and <footer> identify the overall page; headers and footers nested inside articles have different semantics. Give repeated navigation or complementary regions distinguishing labels.
  • Choose a sensible DOM order. CSS order and named grid areas change visual placement. Normal screen-reader reading and keyboard navigation follow the underlying document. Review the exported markup and test Tab navigation at wide and narrow widths; use a skip link to help users reach the main content.
  • Keep essential controls reachable. Hiding a sidebar removes its contents from view and normal keyboard access. Provide another accessible route to essential navigation or actions before choosing Hide.
  • Test real content and zoom. Replace starter links and text, check focus visibility and color contrast, and test narrow widths, zoom, long headings, images and tables. Semantic elements are a starting point, not automatic accessibility certification.

Frequently Asked Questions FAQs

Is this CSS layout generator free?

Yes. Toolslight’s CSS Layout Generator is free to use and does not require an account to customize presets, preview layouts or export HTML and CSS.

Choose from six page presets, edit the structure and styling, then copy the code or download a standalone HTML file or ZIP. The output is editable, so you can replace the starter content and continue working in your own editor.

Can I create a responsive two-column or three-column CSS layout?

Yes. Enable one sidebar for a two-column content row or both sidebars for three columns, then choose how those regions stack or hide on mobile.

Classic starts with a left sidebar, Blog with a right sidebar, and Holy Grail with both. In Grid mode, fixed sidebar tracks sit beside a flexible main track. In Flexbox mode, sidebar flex-basis values define their starting widths. These are page-region layouts, not newspaper-style CSS multi-column text.

How does the generated layout adapt to mobile screens?

The generated CSS switches the content row to a single-column Grid at your chosen breakpoint, which defaults to 768px. This mobile rule applies to both the Grid and Flexbox export modes.

The media query uses @media (max-width: 768px) at the default setting, including the boundary itself. Sidebar controls determine stacking or hiding, while order sets the visual sequence. The three preview modes do not create three breakpoints. Test the exported page around the chosen boundary, because visual reordering does not change its DOM reading order.

Does the exported layout need JavaScript, Bootstrap or Tailwind CSS?

No. The exported page layout uses HTML and native CSS, with no required JavaScript or CSS framework for its layout behavior.

The online generator uses JavaScript for controls, previews and file creation. Menus, dialogs and other interactive features you add need their own behavior. You can integrate the layout with Bootstrap or Tailwind, but the generator exports ordinary CSS selectors rather than framework utility classes.

Can I use the generated HTML and CSS in WordPress or React?

Yes, after adapting the markup and stylesheet to your project. The export is a page-layout starting point, not an installable WordPress theme or a ready-made React component package.

For React, convert HTML to JSX, including class to className, and load the CSS. For WordPress, integrate the required regions with your theme or component and enqueue the styles. Prefer the layout-only code tabs for an existing site, and avoid duplicating its main landmark or unintentionally importing downloaded html and body rules.

How does the generator convert pixels to rem units?

The Root em output option converts the layout’s size-control values using a 16px reference, so 32px becomes 2rem. The mobile breakpoint remains in pixels.

In the finished page, rem values follow the root element’s computed font size. If that size is 20px, a generated 2rem gap becomes 40px. Check the destination site’s root font size and the exported page rather than assuming the preview’s pixel dimensions will stay identical after integration.

Can I save a layout or share its settings?

Yes. Save design stores one configuration in the current browser, while Copy share link creates a URL containing the layout settings.

Saving again replaces the saved configuration, and Load saved restores it on that browser and device. Clearing browser storage can remove it. A share link lets another person load those settings; it is not a hosted copy of a finished website or a backup of content you later add to the exported files.

What should I do if the HTML/CSS ZIP download fails?

Download Standalone HTML, or download HTML only and CSS only separately. Both alternatives let you keep the layout without generating a ZIP.

ZIP creation loads an additional JavaScript library on demand, so a blocked or failed request can prevent that export. For the separate downloads, keep index.html and styles.css together. The standalone file embeds its stylesheet; the ZIP normally contains index.html, styles.css and README.txt.

Should I use CSS Grid or Flexbox for my page layout?

Use CSS Grid when rows and columns need a shared track structure. Use Flexbox when distributing and aligning items along one main axis, such as a row or column.

For a sidebar page, compare Grid’s grid-template-columns with Flexbox’s flex-basis and flex-grow rules. You can also use Grid for the page and Flexbox inside individual regions. The generator’s Flexbox mode still uses Grid for the mobile content row, so inspect the output if your project has specific browser-support requirements.

What is a Holy Grail layout in CSS?

A Holy Grail layout places a flexible main column between two sidebars, with a header above and a footer below. On small screens, those columns commonly become a vertical stack.

Toolslight’s Holy Grail preset also includes a navigation region. Its default Grid content row uses 190px minmax(0, 1fr) 230px, and you can edit both sidebar widths. The current export uses nested containers and track sizing; the guide’s grid-template-areas example is an optional adaptation after export.

Why does my CSS Grid or Flexbox layout overflow horizontally?

Common causes are oversized content, automatic minimum sizes or fixed sidebars that leave too little space. Use min-width: 0 on shrinking regions and, in Grid, minmax(0, 1fr) for a flexible track that can shrink.

The generator already includes these core sizing rules. Still constrain images, wrap long text and allow wide code blocks or tables to scroll when appropriate. If the sidebars and gaps are too wide for the viewport, reduce them or move the stacking breakpoint upward. Avoid masking clipped content with page-wide overflow: hidden.

Can CSS Grid be responsive without media queries, and how do auto-fit and auto-fill differ?

Yes: repeat() with auto-fit or auto-fill and minmax() can change the number of columns as space changes. auto-fill retains empty tracks, while auto-fit collapses empty repeated tracks so occupied tracks can expand.

This pattern suits a card list inside your main content region. Toolslight’s page-shell export instead uses a configurable media-query breakpoint; there is no auto-fit card-grid control. Add that inner grid manually, and choose a minimum track size that can fit its narrowest container.