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
| Attribute | Value | Description |
|---|---|---|
justify-content | space-evenly | Equal space around and between items |
justify-content | space-around | Equal space around items (half-size on ends) |
justify-content | space-between | Equal space between items (no space on ends) |
justify-content | center | Items centered in container |
justify-content | start | Items packed at start (default) |
justify-content | end | Items packed at end |
โ๏ธ
justify-content: space-evenly - Equal space around and between all itemsCode Example
PREVIEW READY
๐
justify-content: space-around - Equal space around items (half-size on ends)Code Example
PREVIEW READY
โ๏ธ
justify-content: space-between - Equal space between items (no space on ends)Code Example
PREVIEW READY
๐ฏ
justify-content: center - Items centered in containerCode Example
PREVIEW READY
โฌ
๏ธ
justify-content: start - Items packed at start (default)Code Example
PREVIEW READY
โก๏ธ
justify-content: end - Items packed at endCode Example
PREVIEW READY
๐ธ align-content Property
| Attribute | Value | Description |
|---|---|---|
align-content | space-evenly | Equal space around and between rows |
align-content | space-around | Equal space around rows (half-size on ends) |
align-content | space-between | Equal space between rows (no space on ends) |
align-content | center | Rows centered in container |
align-content | start | Rows packed at start (default) |
align-content | end | Rows packed at end |
โ๏ธ
align-content: space-evenly - Equal space around and between all rowsCode Example
PREVIEW READY
๐
align-content: space-around - Equal space around rows (half-size on ends)Code Example
PREVIEW READY
โ๏ธ
align-content: space-between - Equal space between rows (no space on ends)Code Example
PREVIEW READY
๐ฏ
align-content: center - Rows centered in containerCode Example
PREVIEW READY
โฌ๏ธ
align-content: start - Rows packed at start (default)Code Example
PREVIEW READY
โฌ๏ธ
align-content: end - Rows packed at endCode Example
PREVIEW READY
๐ธ place-content Property
| Attribute | Value | Description |
|---|---|---|
place-content | normal | Default behavior for content alignment |
place-content | stretch | Stretches items to fill the container |
place-content | start | Aligns content to the start (top/left) |
place-content | end | Aligns content to the end (bottom/right) |
place-content | center | Centers content vertically and horizontally |
place-content | space-between | Equal space between rows and columns |
place-content | space-around | Equal space around rows and columns |
place-content | space-evenly | Equal space around and between rows/columns |
place-content | end start | Vertically aligned to end, horizontally to start |
place-content | space-between start | Vertical: space-between, Horizontal: start |
place-content | space-around end | Vertical: space-around, Horizontal: end |
๐ place-content: normal
Default content positioning.
Code Example
PREVIEW READY
๐ place-content: stretch
Content stretches to fill space.
Code Example
PREVIEW READY
โฌ ๏ธ place-content: start
Content aligned to top/left.
Code Example
PREVIEW READY
โก๏ธ place-content: end
Content aligned to bottom/right.
Code Example
PREVIEW READY
๐ฏ place-content: center
Content centered both vertically and horizontally.
Code Example
PREVIEW READY
โ๏ธ place-content: space-between
Equal spacing between content blocks.
Code Example
PREVIEW READY
๐ place-content: space-around
Equal spacing around each content block.
Code Example
PREVIEW READY
โ๏ธ place-content: space-evenly
Equal spacing around and between content.
Code Example
PREVIEW READY
๐ place-content: end start
Bottom vertically, left horizontally.
Code Example
PREVIEW READY
๐งญ place-content: space-between start
Vertically spaced, horizontally left-aligned.
Code Example
PREVIEW READY
๐ place-content: space-around end
Vertically spaced, horizontally right-aligned.
Code Example
PREVIEW READY
Keep Going!CSS - Grid Items