Skip to main content
InterviewHubPRO
Section Overview
Q17

Question 17 of 50

Part 2: Core Architecture & Implementation (Mid-Level)

34%
CSS3 & Modern Layouts (50 Qs)•Part 2: Core Architecture & Implementation (Mid-Level)

What is CSS Subgrid (`grid-template-columns: subgrid`)?

senior LevelCode ExampleComponentsSystem Design

In Simple Words: In standard CSS Grid, children of a grid item cannot participate in the parent grid's column tracks; they must manage their own nested layout. Subgrid allows a child grid to inherit and align with the parent grid's tracks:

css
.parent-grid {
  display: grid;
  grid-template-columns: 200px 1fr 100px;
}

.child-card {
  grid-column: 1 / -1; /* Spans all 3 parent columns */
  display: grid;
  grid-template-columns: subgrid; /* Shares exact parent track widths! */
}

Ensures headers, bodies, and footers across different cards align perfectly with each other regardless of differing content lengths!