CSS grid-template-columns: subgrid allows a child element of a grid container to participate in the sizing and alignment of the parent grid tracks, rather than creating an independent grid.
CSS Subgrid
Align nested grid items with the parent grid tracks.
Key Takeaways: CSS Subgrid
Mastering CSS Subgrid helps you write clean and reliable CSS code. Follow standard conventions, test edge cases, and keep logic simple. Try running the code example below and complete the exercises to build confidence.
CSS Subgrid Code Example
CSS.parent { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.child-card { display: grid; grid-column: span 3; grid-template-columns: subgrid; }
Output
Child cards align perfectly across parent column lines
Free sign-in required · Google login available
Finished this lesson?
Mark it complete to track your progress.
Stuck on something?
Ask the community in the CodesInTech forum.
Need a developer?
Learning on your own is great — and when you need professional help, our team builds custom software, websites and mobile apps for clients worldwide.
Explore Our Services