Nearby lessons

6 of 15

๐Ÿ”ฒ CSS Grid Container

๐Ÿ“Œ What is a Grid Container?

The grid container is the parent element where the CSS Grid layout starts. ๐ŸŽฏ It defines the grid structure and controls how grid items (children) are placed.

Using display: grid or display: inline-grid turns any HTML element into a grid container.

This section covers each grid container property with clear examples so you can confidently build complex, responsive layouts using CSS Grid. ๐Ÿš€๐ŸŽจ

๐Ÿ“‹ What Can Grid Container Do?

  • ๐Ÿ“ฆ Create rows and columns with ease
  • ๐Ÿงฉ Place items in precise grid locations
  • โš™๏ธ Control spacing, alignment, and gaps

๐Ÿ”ธ justify-content Property

AttributeValueDescription
justify-contentspace-evenlyEqual space around and between items
justify-contentspace-aroundEqual space around items (half-size on ends)
justify-contentspace-betweenEqual space between items (no space on ends)
justify-contentcenterItems centered in container
justify-contentstartItems packed at start (default)
justify-contentendItems packed at end
โš–๏ธ justify-content: space-evenly - Equal space around and between all items
Code Example
PREVIEW READY
Loading Editor...
Live Preview
๐Ÿ”„ justify-content: space-around - Equal space around items (half-size on ends)
Code Example
PREVIEW READY
Loading Editor...
Live Preview
โ†”๏ธ justify-content: space-between - Equal space between items (no space on ends)
Code Example
PREVIEW READY
Loading Editor...
Live Preview
๐ŸŽฏ justify-content: center - Items centered in container
Code Example
PREVIEW READY
Loading Editor...
Live Preview
โฌ…๏ธ justify-content: start - Items packed at start (default)
Code Example
PREVIEW READY
Loading Editor...
Live Preview
โžก๏ธ justify-content: end - Items packed at end
Code Example
PREVIEW READY
Loading Editor...
Live Preview

๐Ÿ”ธ align-content Property

AttributeValueDescription
align-contentspace-evenlyEqual space around and between rows
align-contentspace-aroundEqual space around rows (half-size on ends)
align-contentspace-betweenEqual space between rows (no space on ends)
align-contentcenterRows centered in container
align-contentstartRows packed at start (default)
align-contentendRows packed at end
โš–๏ธ align-content: space-evenly - Equal space around and between all rows
Code Example
PREVIEW READY
Loading Editor...
Live Preview
๐Ÿ”„ align-content: space-around - Equal space around rows (half-size on ends)
Code Example
PREVIEW READY
Loading Editor...
Live Preview
โ†”๏ธ align-content: space-between - Equal space between rows (no space on ends)
Code Example
PREVIEW READY
Loading Editor...
Live Preview
๐ŸŽฏ align-content: center - Rows centered in container
Code Example
PREVIEW READY
Loading Editor...
Live Preview
โฌ†๏ธ align-content: start - Rows packed at start (default)
Code Example
PREVIEW READY
Loading Editor...
Live Preview
โฌ‡๏ธ align-content: end - Rows packed at end
Code Example
PREVIEW READY
Loading Editor...
Live Preview

๐Ÿ”ธ place-content Property

AttributeValueDescription
place-contentnormalDefault behavior for content alignment
place-contentstretchStretches items to fill the container
place-contentstartAligns content to the start (top/left)
place-contentendAligns content to the end (bottom/right)
place-contentcenterCenters content vertically and horizontally
place-contentspace-betweenEqual space between rows and columns
place-contentspace-aroundEqual space around rows and columns
place-contentspace-evenlyEqual space around and between rows/columns
place-contentend startVertically aligned to end, horizontally to start
place-contentspace-between startVertical: space-between, Horizontal: start
place-contentspace-around endVertical: space-around, Horizontal: end

๐Ÿ“„ place-content: normal

Default content positioning.
Code Example
PREVIEW READY
Loading Editor...
Live Preview

๐Ÿ“ place-content: stretch

Content stretches to fill space.
Code Example
PREVIEW READY
Loading Editor...
Live Preview

โฌ…๏ธ place-content: start

Content aligned to top/left.
Code Example
PREVIEW READY
Loading Editor...
Live Preview

โžก๏ธ place-content: end

Content aligned to bottom/right.
Code Example
PREVIEW READY
Loading Editor...
Live Preview

๐ŸŽฏ place-content: center

Content centered both vertically and horizontally.
Code Example
PREVIEW READY
Loading Editor...
Live Preview

โ†”๏ธ place-content: space-between

Equal spacing between content blocks.
Code Example
PREVIEW READY
Loading Editor...
Live Preview

๐Ÿ”„ place-content: space-around

Equal spacing around each content block.
Code Example
PREVIEW READY
Loading Editor...
Live Preview

โš–๏ธ place-content: space-evenly

Equal spacing around and between content.
Code Example
PREVIEW READY
Loading Editor...
Live Preview

๐Ÿ“ place-content: end start

Bottom vertically, left horizontally.
Code Example
PREVIEW READY
Loading Editor...
Live Preview

๐Ÿงญ place-content: space-between start

Vertically spaced, horizontally left-aligned.
Code Example
PREVIEW READY
Loading Editor...
Live Preview

๐ŸŽŒ place-content: space-around end

Vertically spaced, horizontally right-aligned.
Code Example
PREVIEW READY
Loading Editor...
Live Preview
Keep Going!CSS - Grid Items