FAQ: Your First Sass Stylesheet - Maps & Lists

This community-built FAQ covers the “Maps & Lists” exercise from the lesson “Your First Sass Stylesheet”.

Paths and Courses
This exercise can be found in the following Codecademy content:

Learn Sass

FAQs on the exercise Maps & Lists

There are currently no frequently asked questions associated with this exercise – that’s where you come in! You can contribute to this section by offering your own questions, answers, or clarifications on this exercise. Ask or answer a question by clicking reply (reply) below.

If you’ve had an “aha” moment about the concepts, formatting, syntax, or anything else with this exercise, consider sharing those insights! Teaching others and answering their questions is one of the best ways to learn and stay sharp.

Join the Discussion. Help a fellow learner on their journey.

Ask or answer a question about this exercise by clicking reply (reply) below!

Agree with a comment or answer? Like (like) to up-vote the contribution!

Need broader help or resources? Head here.

Looking for motivation to keep learning? Join our wider discussions.

Learn more about how to use this guide.

Found a bug? Report it!

Have a question about your account or billing? Reach out to our customer support team!

None of the above? Find out where to ask other questions here!

Hello,

I don’t understand what this line means : “You can also surround a list with parentheses and create lists made up of lists.”

Could someone help me out, thanks alot!

Have a good day

Maurice Moss! :slight_smile:

The exercise shows this example of a list:

$standard-border: 4px solid black;

But sometimes we want to define values for “different occasions”. Let’s say that we want to use different borders for error messages, or for informative messages.

In situations like this we can define a list of lists:

$borders: (
  standard 2px solid black,
  error 4px double red,
  info 2px dotted blue
);

This will be introduced later in the course, but to make this example complete I have to note that we now can use this list to define different classes using a loop, like so:

@each $border in $borders {
  .border-#{nth($border, 1)} {
    border-width: nth($border, 2);
    border-style: nth($border, 3);
    border-color: nth($border, 4);
  }
}

This syntax is probably strange for you now, but these two snippets combined will result in this CSS code:

.border-standard {
  border-width: 2px;
  border-style: solid;
  border-color: black;
}

.border-error {
  border-width: 4px;
  border-style: double;
  border-color: red;
}

.border-info {
  border-width: 2px;
  border-style: dotted;
  border-color: blue;
}

That is an example of a list of lists in SASS :slight_smile:

IT Crowd fellow fan? :smiley:

Thanks alot for your help I understand now!

Have a great day!

You’re very welcome :slight_smile:

Of course! May the Elders of the Internet lead you :slight_smile:

1 Like