Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to nest the .button styles inside .container.
SASS
.container {
[1] {
color: blue;
}
} Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using an ID selector (#button) instead of a class selector.
Forgetting the dot before the class name.
Using the element selector without a dot.
✗ Incorrect
In Sass, to nest styles for a class inside another, you write the nested class selector inside the parent block. Here,
.button is nested inside .container.2fill in blank
mediumComplete the code to nest the :hover pseudo-class inside .link.
SASS
.link {
[1] {
text-decoration: underline;
}
} Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Writing
:hover without &.Using class or ID selectors instead of pseudo-classes.
✗ Incorrect
In Sass, to nest a pseudo-class like
:hover, use the ampersand & to refer to the parent selector, then add the pseudo-class.3fill in blank
hardFix the error in the nested Sass code to correctly style li elements inside ul.menu.
SASS
ul.menu {
[1] li {
padding: 10px;
}
} Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using combinators like
> incorrectly inside the selector.Adding pseudo-classes when not needed.
✗ Incorrect
To nest
li inside ul.menu, use & li where the ampersand & refers to the parent selector.4fill in blank
hardFill both blanks to create a nested Sass rule that styles p elements inside .card only when hovered.
SASS
.card {
[1] {
[2] {
color: red;
}
}
} Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using
:hover without & which refers to the wrong selector.Nesting
:hover before the element selector.✗ Incorrect
First, nest the
p elements inside .card. Then nest the hover state using &:hover to style p only when the p is hovered.5fill in blank
hardFill all three blanks to write a Sass nested rule that styles span inside .alert when span has class .active and is hovered.
SASS
.alert {
[1] {
[2] {
[3] {
font-weight: bold;
}
}
}
} Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using
.active without &, which targets a child instead of the parent.Placing
:hover before .active.Not nesting selectors in the correct order.
✗ Incorrect
First, nest the
span inside .alert. Then nest the class .active using &.active. Finally, nest the hover state with &:hover to style span only when it is active and hovered.