0
0
CSSmarkup~20 mins

Grid item placement 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!
selector
intermediate
2:00remaining
Which CSS rule places the grid item in the second column and third row?
Given a grid container, which CSS property and value correctly place a grid item in the second column and third row?
CSS
/* Assume the grid container has 4 columns and 4 rows */
.grid-item {
  /* Your code here */
}
Agrid-column-start: 2; grid-row-start: 3;
Bgrid-column: 2; grid-row: 3;
Cgrid-column: 3 / 4; grid-row: 2 / 3;
Dgrid-column-start: 3; grid-row-start: 2;
Attempts:
2 left
💡 Hint
Use the properties that specify the start line for column and row.
layout
intermediate
2:00remaining
What is the visual result of this grid item placement?
Consider a 3x3 grid container. The CSS below is applied to a grid item. What will you see in the browser?
CSS
.grid-container {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 100px);
  gap: 10px;
}
.grid-item {
  grid-column: 2 / 4;
  grid-row: 1 / 3;
  background-color: lightblue;
}
AA light blue box spanning only column 2 and row 1.
BA light blue box spanning columns 1 and 2 and rows 2 and 3.
CA light blue box spanning columns 2 and 3 and rows 1 and 2.
DA light blue box spanning all three columns and rows.
Attempts:
2 left
💡 Hint
Look at the grid-column and grid-row values as start/end lines.
🧠 Conceptual
advanced
2:00remaining
What error occurs if you set grid-column: 5 / 7 on a 4-column grid?
If a grid container has 4 columns, what happens when a grid item has grid-column: 5 / 7;?
CSS
.grid-container {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
}
.grid-item {
  grid-column: 5 / 7;
}
AThe item will not be displayed because the column lines 5 and 7 do not exist.
BThe item will span from the 5th to the 7th column lines, creating extra columns automatically.
CThe browser will ignore the invalid lines and place the item in the first column.
DThe item will span from column 5 to 7, but only columns 5 and 6 will be visible.
Attempts:
2 left
💡 Hint
CSS Grid will create implicit grid tracks if the specified lines are outside the explicit grid.
accessibility
advanced
2:00remaining
How to ensure keyboard users can navigate grid items placed with CSS grid?
When using CSS grid to place items visually, what should you do to keep keyboard navigation logical and accessible?
AArrange the HTML source order to match the visual grid order or use ARIA roles to define reading order.
BUse tabindex="0" on all grid items and rely on visual order only.
CUse CSS to reorder items visually and ignore source order since keyboard users don't rely on it.
DDisable keyboard navigation on grid items to avoid confusion.
Attempts:
2 left
💡 Hint
Keyboard navigation follows the HTML source order, not visual placement.
📝 Syntax
expert
2:00remaining
What is the output of this CSS grid shorthand placement?
Given the CSS below, what is the final grid area occupied by the item?
CSS
.grid-item {
  grid-area: 2 / 3 / 4 / 5;
}
AThe CSS is invalid and will cause a syntax error.
BThe item starts at column line 2, row line 3, ends at column line 4, row line 5, spanning 2 columns and 2 rows.
CThe item occupies the named grid area '2 / 3 / 4 / 5' as a string.
DThe item starts at row line 2, column line 3, ends at row line 4, column line 5, spanning 2 rows and 2 columns.
Attempts:
2 left
💡 Hint
Remember the order of values in grid-area shorthand: row-start / column-start / row-end / column-end.