Challenge - 5 Problems
Grid Mastery Badge
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate1:30remaining
Understanding the purpose of a grid system mixin
What is the main benefit of using a grid system mixin in Sass when building layouts?
Attempts:
2 left
💡 Hint
Think about how mixins help avoid repeating code and keep layouts consistent.
✗ Incorrect
A grid system mixin in Sass helps you write layout code once and reuse it with different settings. This makes your CSS cleaner and your layouts consistent.
📝 Syntax
intermediate2:00remaining
Sass mixin syntax for grid columns
Which of the following Sass mixin definitions correctly accepts two parameters: $columns and $gutter, and sets the width and margin-right accordingly?
Attempts:
2 left
💡 Hint
Remember to use interpolation inside calc() for Sass variables.
✗ Incorrect
In Sass, when using variables inside calc(), you must interpolate them with #{} to output valid CSS.
❓ rendering
advanced2:00remaining
Visual output of grid mixin with gutter
Given this Sass mixin and usage, what will be the width and margin-right of the .item element in the compiled CSS?
SASS
@mixin grid($columns, $gutter) { width: calc((100% / #{$columns}) - #{$gutter}); margin-right: $gutter; } .item { @include grid(4, 1rem); }
Attempts:
2 left
💡 Hint
Look carefully at how Sass outputs variables inside calc() with interpolation.
✗ Incorrect
The mixin outputs width: calc((100% / 4) - 1rem); exactly because of the interpolation syntax. It does not simplify to 25% automatically.
❓ selector
advanced1:30remaining
Selecting last grid item to remove margin
In a grid layout using a mixin that adds margin-right to each item, which CSS selector correctly targets every 4th item to remove its margin-right?
Attempts:
2 left
💡 Hint
Think about how to select every 4th element, not just the 4th or last one.
✗ Incorrect
:nth-child(4n) selects every 4th child (4, 8, 12, ...), which is needed to remove margin on last items in each row.
❓ accessibility
expert2:00remaining
Ensuring accessible grid layout with ARIA roles
When building a grid layout with a custom Sass mixin, which ARIA role should you add to the container to best communicate the grid structure to screen readers?
Attempts:
2 left
💡 Hint
Consider ARIA roles that describe a grid of items, not just a list or table.
✗ Incorrect
The role="grid" tells assistive technologies that the container is a grid structure, improving navigation and understanding.