Skip to content
⚠ TESTING ENVIRONMENT You are viewing a testing copy of Tolioo. Changes here do not affect the live website.

CSS Grid Generator

Build a CSS Grid layout visually. Set columns, rows and gaps, drag across the cells to place items, and copy clean HTML and CSS code. Includes ready-made layouts.

  • 100% free
  • No Signup
  • Runs in your browser
Preview

Drag across the dashed cells to create an item. You can fine-tune each item below.

Items
    CSS
    
            
    HTML
    
            
    ADVERTISEMENT
    Demo Ad 728 x 90

    Build a CSS Grid layout in 3 simple steps

    1. 1

      Set up the grid

      Choose columns, rows, track sizes and gaps, or start from a preset.

    2. 2

      Place your items

      Drag across the cells to create items, then adjust their position.

    3. 3

      Copy the code

      Copy the generated CSS and HTML into your project.

    CSS GRID GUIDE

    Free CSS Grid Generator – Build Grid Layouts Visually and Get Clean HTML and CSS

    CSS Grid is the most powerful layout system on the web. It lets you design pages in rows and columns at the same time, place items exactly where you want them, and build complex layouts, such as dashboards, galleries, magazine pages and holy grail layouts, with a few lines of CSS and no hacks. The syntax, however, takes time to learn. This free CSS Grid generator, also known as a CSS grid layout builder or grid playground, lets you build the layout visually and then copy clean HTML and CSS.

    Set the number of columns and rows, type a size for every track, adjust the gaps, then drag across the cells to create items that span them. You can switch between line numbers and grid-template-areas, start from a preset such as Holy grail, Blog, Gallery or Dashboard, and see the result live. Everything runs in your browser, so there is no signup, no installation and nothing is uploaded.

    Visual Grid Builder

    Set columns, rows, track sizes and gaps, and see the grid change live as you work.

    Drag to Place Items

    Drag across the cells to create an item that spans them, then fine-tune its start and end lines.

    Clean HTML and CSS

    Copy ready-to-use code with line numbers or grid-template-areas, using standard CSS with no dependencies.

    What Is CSS Grid?

    CSS Grid Layout, usually called CSS Grid, is a two-dimensional layout system built into CSS. You turn an element into a grid container with display: grid, define its columns and rows, and then its children become grid items that can be placed in the cells. Unlike older techniques such as floats, tables and inline-block layouts, Grid was designed for layout from the start, so the code is shorter, more readable and far easier to change.

    Grid works in all modern browsers, including Chrome, Edge, Firefox and Safari. If you can describe a layout as rows and columns on paper, you can describe it in CSS Grid.

    How to Use the CSS Grid Generator (Step by Step)

    You can have a working layout in less than a minute.

    1. Start with a preset or a blank grid: Pick a ready-made layout such as Holy grail, Blog, Gallery or Dashboard, or set the number of columns and rows yourself.
    2. Set the track sizes: Type a size for each column and row, such as 1fr, 250px, auto or minmax(100px, 1fr).
    3. Adjust the gaps and alignment: Set the column gap and row gap, and choose how items are aligned inside their cells.
    4. Create your items: Drag across the dashed cells to add an item, or click Add item. Rename it, and change its column and row start and end lines.
    5. Copy the code: Choose line numbers or named areas, then copy the CSS and HTML into your project.

    The Main CSS Grid Properties

    CSS Grid properties and what they do
    Property What it does
    display: grid Turns an element into a grid container.
    grid-template-columns Defines the number and width of columns.
    grid-template-rows Defines the number and height of rows.
    gap, row-gap, column-gap Sets the space between rows and columns.
    grid-column, grid-row Places an item using start and end lines.
    grid-area Places an item by name, or by all four lines at once.
    grid-template-areas Draws the layout with named areas.
    justify-items, align-items Aligns items inside their cells.
    justify-content, align-content Aligns the whole grid inside its container.

    Understanding grid-template-columns and the fr Unit

    The grid-template-columns property lists the width of each column, separated by spaces. The value 200px 1fr 200px creates three columns, with two fixed sidebars and a flexible middle column. The fr unit is the one that makes Grid so convenient: it means a fraction of the free space, after fixed sizes and gaps are taken out. Three columns of 1fr share the space equally, and 1fr 2fr gives the second column twice the width of the first. You can mix fr with px, rem, auto and minmax() in the same grid.

    .grid-container {
        display: grid;
        grid-template-columns: 200px 1fr 200px;
        grid-template-rows: auto 1fr auto;
        gap: 10px;
    }

    Grid Lines, grid-column and grid-row

    A grid with three columns has four vertical lines, numbered 1 to 4 from the left, and a grid with three rows has four horizontal lines. You place an item by saying which lines it starts and ends at. The declaration grid-column: 1 / 3 means that an item starts at line 1 and ends at line 3, so it covers the first two columns. The keyword span gives the same result in another way: grid-column: 1 / span 2. Negative numbers count from the end, so 1 / -1 always stretches an item across the whole width, however many columns there are.

    Named Areas With grid-template-areas

    With grid-template-areas, you draw the layout as text. Each string is a row, each word is a cell, and a dot marks an empty cell. A header that spans the whole width can be written as "header header", and a sidebar next to the main content as "sidebar main". Every item then gets a name with grid-area, and the CSS reads almost like a picture of the page. This makes it easy to understand and to change inside a media query for mobile screens.

    .grid-container {
        display: grid;
        grid-template-columns: 200px 1fr;
        grid-template-areas:
            "header header"
            "sidebar main"
            "footer footer";
    }
    .header { grid-area: header; }

    Areas must be rectangles and cannot overlap, so if your items overlap, the generator uses line numbers instead and tells you why.

    Line Numbers vs Named Areas

    Two ways to place grid items
    Feature Line numbers Named areas
    CSS used grid-column and grid-row grid-template-areas and grid-area
    Readability Precise, but you must count lines Looks like a map of the page
    Overlapping items Allowed Not allowed
    Best for Galleries, dashboards, spanning items Page layouts such as header, sidebar, main and footer

    Grid Presets: Holy Grail, Blog, Gallery and Dashboard

    Presets are a fast way to learn. The holy grail layout has a header, a footer, a main column and two side columns. The blog layout puts a wide article next to a narrower sidebar. The gallery repeats equal cells for images. The dashboard mixes small and large panels that span several rows and columns. Load one, change the track sizes, drag an item to a new position and read how the generated CSS changes. After a few tries, the syntax starts to feel natural.

    CSS Grid vs Flexbox

    Grid and Flexbox are not competitors, they solve different problems. Flexbox is one-dimensional: it lays items out along a single row or a single column, and it is perfect for navigation bars, toolbars, button groups and centering. Grid is two-dimensional: it controls rows and columns together, which makes it the better choice for page layouts, galleries and dashboards. Many real pages use both, with Grid for the page structure and Flexbox for the components inside it. You can try the other model in our CSS Flexbox generator.

    Making Grid Layouts Responsive

    The code that this generator creates is a fixed starting point, and it is easy to adapt to different screens. The simplest way is a media query that redefines the columns for small screens, for example a single column on phones. Another approach does not need media queries at all: grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)) creates as many columns as fit, and each column is at least 240px wide. Cards then rearrange themselves as the screen gets narrower. Combine this with gap for spacing and your layout stays tidy at every width.

    .gallery {
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
        gap: 16px;
    }

    Common CSS Grid Mistakes

    CSS Grid mistakes and fixes
    Mistake How to avoid it
    Mixing up the order in grid-area It is row-start, column-start, row-end, column-end, not x and y.
    Forgetting the height Rows with fr units need a container with a defined height. Without it, they only grow to fit their content.
    Counting tracks instead of lines Three columns have four lines, so spanning the whole width means 1 / 4.
    Overlapping items by accident Two items placed in the same cell are drawn on top of each other.
    Using margins for spacing The gap property is cleaner than margins on each item.
    Fixed widths on small screens Use fr, minmax() or media queries, so the grid does not overflow on phones.

    Who Uses a CSS Grid Generator?

    • Front-end developers: Draft a page layout in seconds and paste it into a template.
    • Designers: Turn a wireframe into real grid code without guessing numbers.
    • Beginners and students: Learn lines, tracks, areas and the fr unit by experimenting.
    • WordPress and Shopify users: Build a custom section or gallery with a small, correct snippet.
    • Teachers: Show how a grid is built, one change at a time.

    Popular Searches This Tool Helps With

    People find this page when they look for a CSS grid generator, CSS grid layout generator, CSS grid builder, grid-template-columns generator, grid-template-areas generator, visual CSS grid editor, CSS grid code generator, a holy grail layout with CSS Grid, a CSS grid gap generator, a responsive grid generator or a CSS grid playground. All of them describe the same need: a quick, visual way to get correct grid code.

    Is the Generated Code Safe to Use? Privacy

    Yes. The output is standard CSS and HTML with no dependencies. Rename the classes to match your project and add your own content. The generator runs in your browser, so your layout is not uploaded or stored on our server, and there is no account or limit.

    Accessibility and Source Order in CSS Grid

    Grid lets you place an item anywhere, which makes it tempting to reorder content visually. Keep in mind that keyboard focus and screen readers follow the order of your HTML, not the position on the screen. Write the HTML in a logical reading order first, then use the grid to position items. If a visual order must differ from the source order, test it with the Tab key and make sure focus never jumps around in a confusing way. A layout that looks right and also reads right is the goal.

    Grid Alignment: Items vs Content

    CSS Grid alignment properties
    Property Applies to What it controls
    justify-items Grid container Horizontal alignment of every item inside its cell.
    align-items Grid container Vertical alignment of every item inside its cell.
    justify-self, align-self Single grid item Overrides the container alignment for one item.
    justify-content Grid container Horizontal position of the whole grid when it is smaller than the container.
    align-content Grid container Vertical position of the whole grid when it is shorter than the container.

    The two groups are easy to mix up. Items alignment moves things inside their cells, while content alignment moves the entire grid inside its container. Use the alignment controls in the generator to see the difference.

    Useful Track Sizes: fr, minmax, auto and repeat

    • 1fr: one share of the free space, perfect for flexible columns.
    • minmax(200px, 1fr): at least 200px wide, growing to share extra space.
    • auto: the size of the content, or the remaining space for the last track.
    • repeat(3, 1fr): a short way to write three equal columns.
    • repeat(auto-fit, minmax(240px, 1fr)): as many columns as fit, a responsive gallery without media queries.

    More Free Developer Tools

    Free CSS Grid Generator Online

    Our free CSS Grid generator makes it easy to design a grid layout, see it live and copy clean HTML and CSS code in seconds. Set up your grid, drag out your items and use the code in your project, with no signup and without anything leaving your browser.

    ADVERTISEMENT
    Demo Ad In-article
    COMMON QUESTIONS

    Frequently Asked Questions About the CSS Grid Generator

    Quick answers about building grid layouts and using the generated code.

    What is a CSS Grid generator?

    A CSS Grid generator is a visual tool that lets you design a grid layout by choosing the number of columns and rows, the size of each track and the gaps, then placing items on the grid. It writes the matching HTML and CSS for you, so you do not have to write grid-template-columns, grid-template-rows and grid-area by hand.

    How do I create a grid layout with this tool?

    Set the number of columns and rows, adjust the track sizes and gaps, and then drag across the cells of the preview to create an item that spans them. You can also start from a preset such as a holy grail or dashboard layout. Copy the CSS and HTML when you are happy with the result.

    What does the fr unit mean in CSS Grid?

    The fr unit means a fraction of the available space. If you have three columns that are all 1fr, they share the space equally. A layout of 1fr 2fr gives the second column twice the width of the first. You can mix fr with px, rem, auto and minmax() in the same grid.

    What is the difference between line numbers and named areas?

    Line numbers place an item with grid-column and grid-row, using the numbered lines between tracks. Named areas use grid-template-areas, where you draw the layout as text and give each item a name with grid-area. Named areas are easy to read for page layouts, but they need items that do not overlap. The generator supports both.

    What is the difference between CSS Grid and Flexbox?

    Flexbox arranges items in one direction, either a row or a column, while CSS Grid arranges items in rows and columns at the same time. Use Grid for page layouts and two-dimensional designs, and Flexbox for aligning items in a single line, such as a navigation bar. They work well together.

    Can I use the generated code on a real website?

    Yes. The output is standard CSS and HTML with no dependencies, and CSS Grid is supported by all modern browsers. Rename the classes to match your project, and add your own content. For responsive designs, you can wrap different grid definitions in media queries.

    Is the CSS Grid generator free? Is my layout saved?

    It is free, with no signup. Everything runs in your browser, and your layout is not uploaded or stored on our server.

    ADVERTISEMENT
    Demo Ad 970 x 250