0
0
CSSmarkup~20 mins

Grid template areas in CSS - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Grid Template Areas Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
1:30remaining
Understanding grid-template-areas layout
Given the following CSS grid template areas, how many grid cells does the area named header cover?
CSS
grid-template-areas: "header header header" "nav main main" "nav footer footer";
A4
B1
C2
D3
Attempts:
2 left
💡 Hint
Count how many times the name 'header' appears in the grid-template-areas string.
📝 Syntax
intermediate
1:30remaining
Identify the syntax error in grid-template-areas
Which option contains a syntax error in the grid-template-areas property?
Agrid-template-areas: "header header" "nav main footer";
Bgrid-template-areas: "header header" "nav main" "footer footer";
Cgrid-template-areas: 'header header' 'nav main';
Dgrid-template-areas: "header header" "nav main";
Attempts:
2 left
💡 Hint
Ensure all row strings have the same number of space-separated area names.
rendering
advanced
2:00remaining
Visual layout from grid-template-areas
What will be the visual layout of the grid areas if the CSS is:
grid-template-columns: 1fr 2fr 1fr;
grid-template-rows: 50px 100px;
grid-template-areas:
  "a a b"
  "c d d";

Which area will be the widest?
AArea 'a' is the widest because it spans two columns, including the 2fr column.
BArea 'b' is the widest because it is in the last column with 1fr width.
CArea 'd' is the widest because it spans two columns but both are 1fr wide.
DArea 'c' is the widest because it occupies the entire first column.
Attempts:
2 left
💡 Hint
Look at how many columns each area covers and their relative widths.
selector
advanced
1:30remaining
Selecting grid areas with CSS selectors
Given this HTML and CSS, which selector correctly styles the grid area named 'sidebar'?
CSS
<div class="container">
  <div class="header">Header</div>
  <div class="sidebar">Sidebar</div>
  <div class="content">Content</div>
</div>

.container {
  display: grid;
  grid-template-areas: "header header"
                       "sidebar content";
}
.sidebar {
  /* Which selector targets this grid area? */
}
A.sidebar { grid-area: header; }
B.container > .sidebar { grid-area: content; }
C.sidebar { grid-area: sidebar; }
D.content { grid-area: sidebar; }
Attempts:
2 left
💡 Hint
The grid-area property assigns the grid area name to the element.
accessibility
expert
2:00remaining
Accessibility considerations with grid-template-areas
When using grid-template-areas for layout, which practice best supports screen reader users?
ARely only on visual grid layout without adding landmarks or roles.
BUse semantic HTML elements and ARIA roles to describe the purpose of each grid area.
CUse only <div> elements with no ARIA attributes inside the grid.
DHide all grid areas from screen readers using <code>aria-hidden="true"</code>.
Attempts:
2 left
💡 Hint
Think about how screen readers understand page structure beyond visual layout.