0
0
SASSmarkup~20 mins

First SASS stylesheet - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
SASS Stylesheet Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
📝 Syntax
intermediate
2:00remaining
What is the compiled CSS output?
Given this SASS code, what is the exact CSS output after compilation?
SASS
$primary-color: #3498db;

.button {
  background-color: $primary-color;
  color: white;
  padding: 1rem 2rem;
  border-radius: 0.5rem;
}
A
.button {
  background-color: #3498db;
  color: white;
  padding: 1rem 2rem;
  border-radius: 0.5rem;
}
B
.button {
  background-color: $primary-color;
  color: white;
  padding: 1rem 2rem;
  border-radius: 0.5rem;
}
C
.button {
  background-color: blue;
  color: white;
  padding: 1rem 2rem;
  border-radius: 0.5rem;
}
D
.button {
  background-color: #3498db;
  color: black;
  padding: 1rem 2rem;
  border-radius: 0.5rem;
}
Attempts:
2 left
💡 Hint
Remember that variables in SASS are replaced with their values during compilation.
layout
intermediate
2:00remaining
How does this nested SASS code render in CSS?
What is the compiled CSS output of this nested SASS code?
SASS
.nav {
  ul {
    margin: 0;
    padding: 0;
    list-style: none;
  }
  li {
    display: inline-block;
  }
  a {
    text-decoration: none;
    color: #333;
  }
}
A
ul {
  margin: 0;
  padding: 0;
  list-style: none;
}
li {
  display: inline-block;
}
a {
  text-decoration: none;
  color: #333;
}
B
.nav ul {
  margin: 0;
  padding: 0;
  list-style: none;
}
.nav li {
  display: inline-block;
}
.nav a {
  text-decoration: none;
  color: #333;
}
C
.nav {
  ul {
    margin: 0;
    padding: 0;
    list-style: none;
  }
  li {
    display: inline-block;
  }
  a {
    text-decoration: none;
    color: #333;
  }
}
D
.nav ul {
  margin: 0;
  padding: 0;
  list-style: none;
}
li {
  display: inline-block;
}
.nav a {
  text-decoration: none;
  color: #333;
}
Attempts:
2 left
💡 Hint
Nested selectors in SASS compile to combined selectors with parent references.
selector
advanced
2:00remaining
Which CSS selector is generated by this SASS code?
What is the CSS selector generated by this SASS snippet?
SASS
.card {
  &-header {
    font-weight: bold;
  }
  &-body {
    padding: 1rem;
  }
}
A
.card {
  -header {
    font-weight: bold;
  }
  -body {
    padding: 1rem;
  }
}
B
.card &-header {
  font-weight: bold;
}
.card &-body {
  padding: 1rem;
}
C
.card-header {
  font-weight: bold;
}
.card-body {
  padding: 1rem;
}
D
.card-header-body {
  font-weight: bold;
  padding: 1rem;
}
Attempts:
2 left
💡 Hint
The & symbol in SASS represents the parent selector.
accessibility
advanced
2:00remaining
How to improve accessibility with SASS variables?
Which SASS code snippet best supports easy color contrast adjustments for accessibility?
A
$background-color: #fff;

body {
  color: #333;
  background-color: $background-color;
}
B
body {
  color: #333;
  background-color: #fff;
}
C
$text-color: #333;

body {
  color: $text-color;
  background-color: #fff;
}
D
$text-color: #333;
$background-color: #fff;

body {
  color: $text-color;
  background-color: $background-color;
}
Attempts:
2 left
💡 Hint
Using variables for both text and background colors allows easy updates for contrast.
🧠 Conceptual
expert
3:00remaining
What is the output of this SASS code with mixins and nesting?
Given this SASS code, what is the compiled CSS output?
SASS
@mixin flex-center {
  display: flex;
  justify-content: center;
  align-items: center;
}

.container {
  @include flex-center;
  height: 100vh;
  .box {
    width: 10rem;
    height: 10rem;
    background: red;
  }
}
A
.container {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100vh;
}
.container .box {
  width: 10rem;
  height: 10rem;
  background: red;
}
B
.container {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100vh;
}
.box {
  width: 10rem;
  height: 10rem;
  background: red;
}
C
.container {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100vh;
  .box {
    width: 10rem;
    height: 10rem;
    background: red;
  }
}
D
.container {
  @include flex-center;
  height: 100vh;
}
.container .box {
  width: 10rem;
  height: 10rem;
  background: red;
}
Attempts:
2 left
💡 Hint
Mixins insert their CSS properties where included. Nested selectors compile with parent prefixes.