Start lines, row placement, alignment, column breaks, and ordering for the items of the CSS Grid system.
Overview
A grid item is a direct child of .grid. This page covers the classes that act on items: where an item starts, how many rows it takes, how it aligns in its cell, and in which order it appears. For the grid itself, spans, and responsive column counts, see the Grid system.
Start line
.col-start-{n} sets grid-column-start, the grid line on which an item starts. Lines are numbered from 1, the start edge of the grid; the classes cover 1 to 12, the lines on which a track starts. An item with no start class goes into the next free tracks. Lines follow the writing direction: under dir="rtl" line 1 is the right edge of the grid.
<div class="grid text-center">
<div class="col-span-4">.col-span-4</div>
<div class="col-span-4 col-start-9">.col-span-4 .col-start-9</div>
</div>Offsetting
A start line leaves the tracks before the item empty. An item that starts at line n has n - 1 tracks before it, so centering a span of six in twelve columns takes .col-start-4.
<div class="grid text-center">
<div class="col-span-3 col-start-4">.col-span-3 .col-start-4</div>
<div class="col-span-3 col-start-10">.col-span-3 .col-start-10</div>
</div>
<div class="grid text-center">
<div class="col-span-6 col-start-4">.col-span-6 .col-start-4</div>
</div>A start line is absolute: it counts from the edge of the grid, not from the previous item. Moving the second of two items takes a start line that accounts for the first.
Responsive start lines
Breakpoint variants set the start line per breakpoint. A start line stays in effect at wider breakpoints until another start class replaces it: a number moves the item to another line, and .col-start-auto returns it to the next free tracks.
<div class="grid text-center">
<div class="col-span-full sm:col-span-5 md:col-span-6">.sm:col-span-5 .md:col-span-6</div>
<div class="col-span-full sm:col-span-5 sm:col-start-8 md:col-span-6 md:col-start-auto">.sm:col-span-5 .sm:col-start-8 .md:col-span-6 .md:col-start-auto</div>
</div>Resetting a span
.col-auto sets grid-column: auto, which takes both the span and the start line off an item, so it occupies one track again. .col-span-1 is not the same: it keeps a span of one.
<div class="grid grid-cols-4 text-center">
<div class="col-span-full md:col-auto">Auto</div>
<div class="col-span-full md:col-auto">Auto</div>
<div class="col-span-full md:col-span-2">.md:col-span-2</div>
</div>Each item is .col-span-full below md; from md the first two carry .md:col-auto and take one of the four tracks each.
Column breaks
.col-start-1 sends an item to the first track, which starts a new row when the item is not there already. No empty element is needed to break a row.
<div class="grid text-center">
<div class="col-span-3">.col-span-3</div>
<div class="col-span-3">.col-span-3</div>
<div class="col-span-3 col-start-1">.col-span-3 .col-start-1</div>
<div class="col-span-3">.col-span-3</div>
</div>End line
.col-end-{n} sets grid-column-end, the line on which an item ends, from 1 to 13, the line after the last track of twelve. With a span it places an item against the end edge of the grid, whatever comes before it; with a start line it sets both edges. .col-end-auto resets an end line at a wider breakpoint.
<div class="grid text-center">
<div class="col-span-3">.col-span-3</div>
<div class="col-span-3 col-end-13">.col-span-3 .col-end-13</div>
<div class="col-start-2 col-end-8">.col-start-2 .col-end-8</div>
</div>The end classes come after the span classes in the CSS, so .col-span-3 .col-end-13 keeps its end line. A span class of a wider breakpoint sets the whole grid-column again: repeat the end class at that breakpoint (.md:col-span-4 .md:col-end-13).
Rows
.row-span-{n} makes an item span n rows, from 1 to 6, .row-start-{n} places it on a row line, from 1 to 6, and .row-end-{n} ends it on one, from 1 to 7. All have breakpoint variants. .row-start-auto and .row-end-auto reset a row line as .col-start-auto resets a column line, and .row-auto takes the span and the line off as .col-auto does.
<div class="grid text-center" style="--cx-grid-columns: 4;">
<div class="row-span-2">.row-span-2</div>
<div class="col-span-3">.col-span-3</div>
<div class="col-span-3">.col-span-3</div>
</div>.grid declares no rows: each line of items creates a row as tall as its content. .grid-rows-{n} sets the number of explicit rows, from 1 to 6, which share the height of the grid equally.
<div class="grid grid-cols-3 grid-rows-3 text-center">
<div>Row 1</div>
<div class="col-start-2 row-start-2">.col-start-2 .row-start-2</div>
<div class="col-start-3 row-start-3">.col-start-3 .row-start-3</div>
</div>Alignment
The tracks of .grid fill its width, and an item fills its cell on both axes. Alignment classes change how an item sits in its cell.
Vertical alignment
.align-items-{value} on the grid aligns every item on the block axis. Available values: start, end, center, baseline, stretch.
<div class="grid align-items-start text-center">
<div class="col-span-4">One of three items</div>
<div class="col-span-4">One of three items</div>
<div class="col-span-4">One of three items</div>
</div><div class="grid align-items-center text-center">
<div class="col-span-4">One of three items</div>
<div class="col-span-4">One of three items</div>
<div class="col-span-4">One of three items</div>
</div><div class="grid align-items-end text-center">
<div class="col-span-4">One of three items</div>
<div class="col-span-4">One of three items</div>
<div class="col-span-4">One of three items</div>
</div>.align-self-{value} on an item overrides the alignment of the grid for that item.
<div class="grid text-center">
<div class="col-span-4 align-self-start">.align-self-start</div>
<div class="col-span-4 align-self-center">.align-self-center</div>
<div class="col-span-4 align-self-end">.align-self-end</div>
</div>Horizontal alignment
.justify-items-{value} on the grid aligns every item on the inline axis of its cell, and .justify-self-{value} does it for one item. Available values: start, end, center, stretch, and auto for .justify-self-*. With start, end, or center an item is as wide as its content; .justify-self-auto returns an item to the alignment of the grid.
<div class="grid justify-items-start text-center">
<div class="col-span-4 px-md">Start</div>
<div class="col-span-4 px-md justify-self-center">.justify-self-center</div>
<div class="col-span-4 px-md justify-self-end">.justify-self-end</div>
</div>Both axes
.place-items-{value} on the grid aligns every item on both axes at once, and .place-self-{value} one item: with start, center, or end an item is as wide as its content and sits at that edge of its cell. .place-content-{value} distributes the tracks themselves, on a grid whose tracks do not fill it.
<div class="grid place-items-center text-center">
<div class="col-span-4 px-xs">Item</div>
<div class="col-span-4 px-xs">Item</div>
<div class="col-span-4 px-xs">Item</div>
</div>Horizontal position
The tracks leave no free space on the inline axis, so .justify-content-* does not move the items of a .grid. Position an item with a start line or an end line, or align it within its cell with .justify-self-*.
<div class="grid text-center">
<div class="col-span-4 col-start-3">.col-span-4 .col-start-3</div>
<div class="col-span-4">.col-span-4</div>
</div>
<div class="grid text-center">
<div class="col-span-4 col-start-5">.col-span-4 .col-start-5</div>
<div class="col-span-4">.col-span-4</div>
</div>Reordering
.order-{n} sets the order property, which changes the visual position of an item without changing the DOM. Values 0 through 5 are generated at all six breakpoints, so the order can change per breakpoint (.order-1.md:order-2). .order-first applies order: -9999 and .order-last order: 9999, so they hold their place beside any other order.
<div class="grid text-center">
<div class="col-span-4">First in DOM, no order applied</div>
<div class="col-span-4 order-5">Second in DOM, with a larger order</div>
<div class="col-span-4 order-1">Third in DOM, with an order of 1</div>
</div><div class="grid text-center">
<div class="col-span-4 order-last">First in DOM, ordered last</div>
<div class="col-span-4">Second in DOM, unordered</div>
<div class="col-span-4 order-first">Third in DOM, ordered first</div>
</div>Visual order does not change the order in which keyboards and screen readers reach the items. Keep the DOM order meaningful and reorder only where the reading order stays the same. The same holds for a start or end line that places an item before earlier ones, and for dense packing.
Widths outside a grid
Span classes do nothing outside a .grid. To give an element a fraction of the width of its parent, use the responsive fraction widths, .w-{n}/12 — see Sizing.
<div class="w-3/12 p-md mb-xs">
.w-3/12: width of 25%
</div>
<div class="sm:w-9/12 p-md">
.sm:w-9/12: width of 75% above sm breakpoint
</div>Float-based layouts combine a fraction width with .float-end or .float-start. Wrap the content in a .clearfix container to contain the float when the text is shorter than the floated element.
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec a diam lectus. Sed sit amet ipsum mauris. Maecenas congue ligula ac quam viverra nec consectetur ante hendrerit.
Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur.
Donec sed odio dui. Nullam quis risus eget urna mollis ornare vel eu leo. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus.
<div class="clearfix">
<img src="..." class="md:w-6/12 md:float-end mb-md md:ms-md" alt="...">
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec a diam lectus. Sed sit amet ipsum mauris. Maecenas congue ligula ac quam viverra nec consectetur ante hendrerit.</p>
<p>Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur.</p>
<p>Donec sed odio dui. Nullam quis risus eget urna mollis ornare vel eu leo. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus.</p>
</div>CSS
The span, start, end, and row classes are generated by make-cssgrid() up to $grid-columns and $grid-rows — see Grid system → Sass variables.
The range of the .order-* utilities comes from the $utilities Sass map. This override adds an .order-6 class; .order-first and .order-last need no change:
@use "@chassis-ui/css/scss/utilities" with (
$utilities-overrides: (
"order": (values: (6: 6)),
)
);
@use "@chassis-ui/css/scss/chassis";Modify utilities describes the $utilities-overrides map, and Sass maps and loops the other maps of the framework.