0
0
SASSmarkup~20 mins

Component-based file organization in SASS - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Sass Component Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
Why use component-based file organization in Sass?
Which of the following is the main benefit of organizing Sass files by components?
AIt makes styles easier to maintain and reuse by grouping related styles together.
BIt allows Sass to compile files faster by compiling each component separately.
CIt reduces the total size of the compiled CSS by removing unused styles automatically.
DIt forces all styles to be global, so they apply everywhere without importing.
Attempts:
2 left
💡 Hint
Think about how grouping related styles helps when projects grow bigger.
📝 Syntax
intermediate
2:00remaining
Correct way to import a component partial in Sass
Given a partial file named _button.scss inside a components folder, which import statement correctly includes it in main.scss?
SASS
/* main.scss */
@import ???;
A@import 'components/_button.scss';
B@import 'components/button';
C@import 'button';
D@import '_button';
Attempts:
2 left
💡 Hint
Remember Sass partials start with underscore but you don't include it in import.
selector
advanced
2:00remaining
Specificity in component-based Sass files
If you have a _card.scss component with styles for .card and a global style for .card in main.scss, which style will apply if both set background-color?
SASS
/* _card.scss */
.card {
  background-color: blue;
}

/* main.scss */
.card {
  background-color: red;
}
AThe red background from main.scss will apply because it is declared last in the compiled CSS.
BThe blue background from _card.scss will apply because component styles are more specific.
CBoth backgrounds will apply, layering colors on top of each other.
DNeither background will apply due to conflict; the element will be transparent.
Attempts:
2 left
💡 Hint
Think about CSS rules: when selectors have the same specificity, which one wins?
layout
advanced
2:00remaining
Using Flexbox in a component partial
You want to create a _navbar.scss component that lays out navigation links horizontally with space between them. Which Sass code snippet correctly uses Flexbox for this?
A
.navbar {
  display: grid;
  justify-content: space-between;
  align-items: center;
}
B
.navbar {
  display: block;
  justify-content: space-between;
  align-items: center;
}
C
.navbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
D
.navbar {
  display: flex;
  justify-items: space-between;
  align-content: center;
}
Attempts:
2 left
💡 Hint
Flexbox uses justify-content and align-items for layout alignment.
accessibility
expert
2:00remaining
Ensuring accessible focus styles in component Sass files
You have a _button.scss component. Which Sass snippet best ensures visible focus outlines for keyboard users without affecting mouse users?
A
.button:focus {
  outline: 3px solid #005fcc;
  outline-offset: 2px;
}
B
.button:focus {
  outline: none;
}
C
.button:hover {
  outline: 3px solid #005fcc;
  outline-offset: 2px;
}
D
.button:focus-visible {
  outline: 3px solid #005fcc;
  outline-offset: 2px;
}
Attempts:
2 left
💡 Hint
Focus outlines should appear only when using keyboard navigation.