Introduction
The parent selector & helps you write CSS rules that relate to the current selector without repeating it. It keeps your styles organized and easy to read.
& { /* nested styles here */ }.button { &-primary { color: blue; } }
.nav { &:hover { background: lightgray; } }
.card { & .title { font-weight: bold; } }
@charset "UTF-8"; .container { background-color: #f0f0f0; padding: 1rem; &-header { font-size: 1.5rem; color: #333; } &:hover { background-color: #e0e0e0; } & .content { margin-top: 1rem; color: #666; } }
& symbol represent in Sass when used inside nested selectors?& in Sass nesting& symbol is used to refer back to the parent selector in nested Sass code.& does in the context& means parent selector [OK]&?& with a pseudo-class is &:hover without spaces or parentheses.&:hover correctly inside the button block.nav {
&.active {
color: blue;
}
ul & {
margin: 0;
}
}&.active usage& refers to nav, so &.active becomes nav.active.ul & usageul nav, because & is replaced by nav but placed after ul..card {
& .title {
font-weight: bold;
}
&.highlight {
background: yellow;
}
&hover {
color: red;
}
}& .title is valid for child selector, &.highlight is valid for combined class.&hover is missing the colon and should be &:hover.li elements inside a ul have a special style only when the ul has a class highlight. Which Sass code using & correctly achieves this?li inside ul.highlight, so the selector is ul.highlight li.&.highlight li inside ul, so & becomes ul, resulting in ul.highlight li.Pass the test and this pattern moves unknown