dense<\/code><\/h4>\n\n\nIf specified, the auto-placement algorithm attempts to fill available space in the grid with smaller items, even if they are out of order in the markup.<\/p>\n\n\n\n
To understand better the dense<\/code> keyword value, let\u2019s establish an 8×8 grid of 50px<\/code> squares as an example:<\/p>\n\n\n\n.grid-container {\n display: grid;\n grid-template-columns: repeat(8, 50px);\n grid-template-rows: repeat(8, 50px);\n}<\/code><\/pre>\n\n\n\nThen we expand the size of some of them:<\/p>\n\n\n\n
.grid-item:is(:nth-child(3), :nth-child(5), :nth-child(8), :nth-child(12), :nth-child(17) {\n grid-column: span 3;\n grid-row: span 2;\n}<\/code><\/pre>\n\n\n\nYou can see the result in the following image:<\/p>\n\n\n\n