GenerateIt

CSS Grid Generator

Below you’ll find a CSS Grid Generator that lets you quickly design modern, responsive layouts without writing everything from scratch. Use the visual controls to define columns, rows, gaps, and alignment, and see the layout update in real time as you make changes. Once you’re happy with your grid, the tool automatically generates clean, production-ready CSS and HTML that you can copy and use directly in your project.

If this site has been useful, we’d love your support! Consider buying us a coffee to keep things going strong.

Buy me a coffee

Start from a layout

Optional

Grid editor

Click a cell, or drag across several cells, to add a div. Click a div to select it, then drag the round handle to move it and the corner square to resize it.

Generated code

Copy & paste
HTML
CSS

Everything is worked out in your browser and nothing is uploaded. The container is set to 100% width and height, so give its parent a height.

How to use it

The grid generator is a visual tool to help you in creating a grid layout for your website.

  1. Start from a layoutClick one of the pre-made layouts, such as a website, a gallery or a set of columns, or begin with an empty grid.
  2. Set the grid sizeChoose how many rows and columns you need, and the gap between them. The grid updates as you change each option.
  3. Add divsClick a cell to add a div, or drag across several cells to add one that spans them. The Add div button puts a new one in the first free cell.
  4. Move and resizeSelect a div, then drag the round handle to move it or the corner square to resize it. You can also type exact lines into the panel.
  5. Fine-tune the sizesOpen Row and column sizes to set each row and column in fr, px, %, em, vw, vh or auto.
  6. Copy the codeThe HTML and CSS are ready as soon as you make a change. Copy them, or open a full-size preview in a new tab.

Good to know

What fr means

1fr is one share of the space that is left. A 2fr column is twice as wide as a 1fr column, however wide the page is.

Lines, not cells

The CSS grid-area is row start / column start / row end / column end. The end line is where the div stops, so a div in the first cell is 1 / 1 / 2 / 2.

Keyboard friendly

Tab to a div and press Enter to select it. Arrow keys move it, Shift with the arrows resizes it, Delete removes it and Escape lets go.

Sizes in the editor

Pixel sizes are drawn to scale for a 1440 pixel wide screen. Open the preview to see the grid at the full size of your window.

Frequently asked questions

Why does my grid have no height?

The generated container has height: 100%, which needs a parent with a height. If you want the grid to fill the window, change it to min-height: 100vh.

How do I make the grid responsive?

Use fr and % for sizes so the grid stretches with the page. For small screens, add a media query that changes grid-template-columns to a single column and puts each div on its own row.

Why do the divs have background colors?

The colors make each div easy to see in the editor and in the preview. Switch off Background colors above the code if you do not want them in your CSS.

How many rows and columns can I have?

Up to 24 of each. Large grids get small on a phone, so the row and column fields and the panel are the easier way to work on those.

Is anything uploaded?

No. The grid, the code and the preview are all created in your browser.

Related tools

CSS Layout Generator

This generator will create a fluid or fixed width column layout, with up to 3 columns + header, footer and menu.

If this site has been useful, we’d love your support! Consider buying us a coffee to keep things going strong.

Buy me a coffee