0
0
CSSmarkup~30 mins

Grid rows and columns in CSS - Mini Project: Build & Apply

Choose your learning style9 modes available
Grid rows and columns
📖 Scenario: You are creating a simple webpage layout using CSS Grid. The page will have a header, a sidebar, a main content area, and a footer arranged in a grid.
🎯 Goal: Build a CSS Grid layout with 3 rows and 3 columns. Place the header spanning all columns in the first row, the sidebar in the first column of the second row, the main content in the second and third columns of the second row, and the footer spanning all columns in the third row.
📋 What You'll Learn
Use CSS Grid to create the layout
Define grid rows and columns with correct sizes
Place grid items in correct grid cells using grid-row and grid-column
Use semantic HTML elements:
,
Ensure the layout is responsive and accessible
💡 Why This Matters
🌍 Real World
Grid layouts are common in modern websites to organize content clearly and responsively.
💼 Career
Understanding CSS Grid is essential for front-end developers to build flexible and accessible web page layouts.
Progress0 / 4 steps
1
Create the HTML structure
Write the HTML code to create a div with class container that contains four elements: a <header> with text 'Header', an <aside> with text 'Sidebar', a <main> with text 'Main Content', and a <footer> with text 'Footer'.
CSS
Need a hint?

Use semantic tags inside the container div exactly as described.

2
Define the grid container with rows and columns
In CSS, select the class .container and set display: grid;. Then define the grid template with grid-template-columns as 1fr 2fr 1fr and grid-template-rows as auto 1fr auto.
CSS
Need a hint?

Use fractional units (fr) for columns and auto for rows as instructed.

3
Place the grid items in correct rows and columns
Add CSS rules to place the header to span all three columns in the first row using grid-column: 1 / 4; and grid-row: 1;. Place the aside in the first column of the second row with grid-column: 1; and grid-row: 2;. Place the main in columns 2 to 3 of the second row with grid-column: 2 / 4; and grid-row: 2;. Finally, place the footer spanning all columns in the third row with grid-column: 1 / 4; and grid-row: 3;.
CSS
Need a hint?

Use grid-column and grid-row properties exactly as described for each element.

4
Add basic styling and accessibility improvements
Add CSS to give each grid item a background color and padding: header background #8ca0ff, aside background #a0d8ef, main background #f0e68c, and footer background #d3a0f0. Add padding of 1rem to all. Also add aria-label attributes to aside as 'Sidebar' and main as 'Main content' in the HTML for accessibility.
CSS
Need a hint?

Add background colors and padding exactly as specified. Add aria-label attributes to aside and main tags.