In CSS Grid, which statement about auto-fill vs auto-fit with minmax is correct?

Prepare for the CSS Mastery SAD Maintenance and CSA Stand Ups Test. With flashcards and multiple choice questions, ready yourself for the exam with hints and explanations for every question. Ace your exam today!

Multiple Choice

In CSS Grid, which statement about auto-fill vs auto-fit with minmax is correct?

Explanation:
When you use repeat(auto-fill, minmax(...)) versus repeat(auto-fit, minmax(...)) in CSS Grid, you’re deciding how many columns can be created and what happens to empty ones. auto-fill creates as many tracks as will fit in the container, even if some of those tracks end up empty because there aren’t enough items to fill them. Those empty tracks remain as blank columns. auto-fit also creates as many tracks as fit, but when there aren’t enough items to populate all of them, the empty tracks collapse, and the remaining tracks stretch to fill the available space. In other words, with fewer items, auto-fit eliminates the empty columns and expands the existing columns to use the extra space. So the statement captures the main distinction: auto-fill leaves empty tracks, while auto-fit collapses those empty tracks to fill space with the existing content. Use auto-fill when you want reserved columns even if they’re empty; use auto-fit when you want the grid to compress unused columns and let content fill the space.

When you use repeat(auto-fill, minmax(...)) versus repeat(auto-fit, minmax(...)) in CSS Grid, you’re deciding how many columns can be created and what happens to empty ones. auto-fill creates as many tracks as will fit in the container, even if some of those tracks end up empty because there aren’t enough items to fill them. Those empty tracks remain as blank columns.

auto-fit also creates as many tracks as fit, but when there aren’t enough items to populate all of them, the empty tracks collapse, and the remaining tracks stretch to fill the available space. In other words, with fewer items, auto-fit eliminates the empty columns and expands the existing columns to use the extra space.

So the statement captures the main distinction: auto-fill leaves empty tracks, while auto-fit collapses those empty tracks to fill space with the existing content. Use auto-fill when you want reserved columns even if they’re empty; use auto-fit when you want the grid to compress unused columns and let content fill the space.

Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy