October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsPC HealthRecommendedCrashes, freezes, slowdowns? Check your PC nowSpot repairable issues before they interrupt work.Check PCOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
World desk4 min

How to Create a 12-Column CSS Grid Layout

Use repeat(12, 1fr) to define twelve equal CSS Grid tracks, place items with lines or spans, and adjust the structure when the content needs to respond to narrower screens.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Create a twelve-column CSS Grid by making the container a grid and defining twelve equal fractional columns: grid-template-columns: repeat(12, 1fr). Place items using grid lines or spans, then adjust those placements—or redefine the columns—when the content needs to adapt to narrower screens.

Build the basic 12-column grid

Apply display: grid and grid-template-columns: repeat(12, 1fr) to the parent. Each 1fr track receives an equal share of the space available to the grid tracks. The gap property sets the spacing between tracks; it is part of the layout, so choose a value that suits the design.

.layout {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 1.25rem;
}

This creates the column structure, but does not automatically assign items to particular columns. Use grid line numbers or spans to place them.

Place items with grid lines and spans

Grid lines mark the boundaries around the tracks. A twelve-track grid has thirteen numbered vertical lines, so grid-column: 1 / 13 starts at the first line and ends at the thirteenth, spanning all twelve columns.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall
Sale
HTML and CSS: Design and Build Websites
  • HTML CSS Design and Build Web Sites
  • Comes with secure packaging
  • It can be a gift option
<div class="layout">
  <header>Site header</header>
  <aside>Related links</aside>
  <main>Main article</main>
  <footer>Site footer</footer>
</div>
.layout {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 1.25rem;
}

header,
footer {
  grid-column: 1 / 13;
}

aside {
  grid-column: 1 / 4;
}

main {
  grid-column: 4 / 13;
}

Here, the header and footer cover the full grid. The aside uses the first three tracks, while the main area begins at line 4 and ends at line 13. You can also specify a start line and a span, such as grid-column: 4 / span 9, to express that an item should occupy nine tracks from its starting line.

These line-based placements follow the approach in MDN’s CSS Grid layout guide. The example’s gap is a design choice, not a required value.

Make the layout responsive

A twelve-column system does not mean an item has to remain narrow on a small screen. At a breakpoint where the content no longer fits comfortably, change item spans or define a different grid. Set the breakpoint based on the content and available space rather than assuming one screen width works for every layout.

Keep twelve tracks and change item spans

One option is to retain the twelve tracks while changing how items are placed at a media-query breakpoint. This preserves the grid’s underlying structure while letting content use more of its width on smaller screens. MDN demonstrates responsive layouts that adjust item spans this way in its common grid layouts guide.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Redefine the grid at a breakpoint

If the twelve-column structure no longer suits the available width, define fewer columns in a media query. For example, a layout with separate sidebar and main areas on a wide screen might stack them on a narrow one. Choose the change based on what the content needs; there is no universally correct breakpoint.

Use named lines for repeated placements

Named lines can make placement rules easier to read when the same grid positions appear repeatedly. This form names each repeated line col-start:

.wrapper {
  display: grid;
  grid-template-columns: repeat(12, [col-start] 1fr);
  gap: 1.25rem;
}

.content {
  grid-column: col-start 4 / span 9;
}

The named line makes the intent more descriptive than relying only on a line number. It is optional; use it when it improves the clarity of your layout rules. MDN documents this pattern in its guide to common grid layouts.

When to use auto-fitting columns instead

A twelve-column grid is useful when multiple regions need predictable spans and alignment. If the number of columns should instead follow the available width, consider an auto-fitting grid:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 1rem;
}

This example asks Grid to fit as many columns as it can, with a minimum track size of 230 pixels and flexible space above that. The minimum is an example to tune for the content, not a universal recommendation. MDN explains both this adaptive pattern and the basics of tracks, lines, and gaps in its basic concepts guide.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Common problems and fixes

  • An item spans too many columns: Check its start and end lines. To span all twelve tracks, use 1 / 13; ending at line 12 covers only through the track before line 12.
  • Items do not line up as expected: Confirm that the grid declaration is on the parent that contains the items you are placing. Grid line placement applies to grid items in that grid.
  • The layout feels cramped: Reconsider both the track placement and gap. Gaps take up space between tracks, so they affect how the complete layout fits.
  • The phone layout stays too wide or crowded: Change item spans or redefine the columns at a content-appropriate breakpoint instead of expecting desktop placements to suit every width.
  • The fixed column count is unnecessary: If the layout should create as many columns as fit, use an auto-fitting definition such as repeat(auto-fit, minmax(...)) and choose a suitable minimum track size.

Or skip the browser setup

If you need a screenshot of a published page to inspect the layout, you can request one with ScreenshotNeo. For a page you are developing locally, publish or otherwise make it reachable at a URL the API can access first.

curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp

See the ScreenshotNeo documentation for request options. ScreenshotNeo accepts cookie and consent banners before capture and removes more than 60 known consent platforms, newsletter popups, and chat widgets; each step can be turned off. Bot checks, blank pages, timeouts, failed loads, and cache hits are not billed, and response headers identify the page verdict and billing status. Its MCP server provides screenshot and page-information tools for AI agents. The free plan includes 1,000 screenshots per month with no card; paid plans start at $5 for 3,000 shots. Learn about ScreenshotNeo or sign up for 1,000 free screenshots a month with no card.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Leave a Reply

Your email address will not be published. Required fields are marked *

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. Shenzhen desk3 min
    HONOR Expands Beyond Smartphones With Humanoid Robot RevealHONOR said it unveiled its first humanoid robot at MWC 2026 and named shopping assistance, workplace inspections, and supportive companionship as intended uses. Later Robotics D1 claims and a reported…
  2. Cupertino desk5 min
    Apple Unveils AirPods Max 2: The Upgrade That Should Have Happened Years AgoAirPods Max 2 adds H2-powered audio features and Apple claims up to 1.5× more effective ANC, but its design, Smart Case, and 20-hour battery rating are unchanged. Wired lossless audio…
  3. Cupertino desk4 min
    Apple’s OLED Touch MacBooks Are Coming—but the Dynamic Island Is the Real GambleApple has not announced an OLED touchscreen MacBook, but reports point to high-end models arriving in late 2026 or early 2027. The reported Mac Dynamic Island could be useful, but…
Recommended PC Tool
Recommended PC Tool
Crashes, No Sound, or Screen Glitches?Free driver scan
Windows Errors? Fix Them Before They SpreadFree repair scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.