Performance: Gap between grid cells
LOW IMPACT
This affects the rendering speed and layout stability by controlling spacing between grid items without extra elements.
<div class="grid grid-cols-3 gap-4"> <div>Item 1</div> <div>Item 2</div> <div>Item 3</div> </div>
<div class="grid grid-cols-3"> <div class="mr-4">Item 1</div> <div class="mr-4">Item 2</div> <div>Item 3</div> </div>
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Margin on grid items | No extra nodes | Multiple reflows (per item) | Higher paint cost due to layout shifts | [X] Bad |
| Grid gap property | No extra nodes | Single reflow for container | Lower paint cost, stable layout | [OK] Good |