<div class="grid grid-cols-3 gap-4"> <div class="col-span-2 bg-blue-500 text-white p-4">Item 1</div> <div class="bg-green-500 text-white p-4">Item 2</div> <div class="bg-red-500 text-white p-4">Item 3</div> </div>
The first item spans 2 columns in the first row, so it occupies columns 1 and 2. The second item fills the remaining third column in the first row. The third item moves to the next row and occupies the first column there.
col-span-3 tells the grid item to span 3 columns. col-start-3 and col-end-3 control where the item starts or ends, not how many columns it spans. col-span-full spans all columns, which may not be exactly 3.
col-span-6, what will happen?When a grid item tries to span more columns than exist, it will span all available columns without causing errors or overflow. It does not wrap automatically.
Spanning columns does not remove the need for keyboard accessibility. The item should remain focusable with a visible focus style and the tab order should follow the visual layout logically.
col-span-2 in a 4-column grid with 1rem gap?col-span-2?The total gap width is 3 gaps ร 1rem = 3rem. The remaining width for columns is 40rem - 3rem = 37rem. Each column is 37rem รท 4 = 9.25rem. Spanning 2 columns means 9.25rem ร 2 = 18.5rem plus 1 gap (1rem) between the two columns, so total width is 18.5rem + 1rem = 19.5rem.