0
0
CSSmarkup~20 mins

Grid rows and columns in CSS - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Grid Mastery Badge
Get all challenges correct to earn this badge!
Test your skills under time pressure!
layout
intermediate
2:00remaining
What is the number of columns in this grid?
Consider the CSS below. How many columns will the grid container have?
CSS
display: grid;
grid-template-columns: repeat(3, 1fr);
A3
B2
C1
D4
Attempts:
2 left
💡 Hint
The repeat function sets how many columns are created.
📝 Syntax
intermediate
2:00remaining
Which option correctly defines 2 rows with different heights?
You want a grid with two rows: the first row 100px tall and the second row 200px tall. Which CSS is correct?
Agrid-rows: 100px 200px;
Bgrid-rows-template: 100px, 200px;
Cgrid-template-rows: 100px, 200px;
Dgrid-template-rows: 100px 200px;
Attempts:
2 left
💡 Hint
The property name is grid-template-rows and values are space-separated without commas.
rendering
advanced
2:00remaining
What will be the height of the second row?
Given this CSS, what is the height of the second row in the grid container?
CSS
display: grid;
grid-template-rows: 100px auto 50px;
A100px
B50px
Cauto
D150px
Attempts:
2 left
💡 Hint
The second value in grid-template-rows sets the second row height.
selector
advanced
2:00remaining
Which CSS selector targets the second column in a grid?
You want to style all items in the second column of a grid container. Which selector will do this?
A.grid-container > :nth-child(2)
B.grid-container > :nth-child(3n+2)
C.grid-container > :nth-child(4n+2)
D.grid-container > :nth-child(2n)
Attempts:
2 left
💡 Hint
Grid items are placed row-wise. Use a formula to select every item in the second column.
accessibility
expert
2:00remaining
How to make a grid accessible for screen readers?
Which practice improves accessibility for a grid layout used as a data table?
AUse semantic <table>, <thead>, <tbody>, and <th> elements instead of divs with CSS grid.
BAdd role="grid" to the container and use divs for all cells.
CUse aria-label on each grid cell and no semantic elements.
DUse only CSS grid with no ARIA roles or semantic tags.
Attempts:
2 left
💡 Hint
Semantic HTML elements help screen readers understand data tables better than ARIA alone.