SASS Online Test Questions part 2

7. Which of the following is the correct way to define a variable in Sass?

a. @primary-color: #888;
b. %primary-color: #888;
c. #primary-color: #888;
d. $primary-color: #888;

Answer: d. $primary-color: #888;

Explanation: Following is the correct way to define a variable in SASS,
$primary-color: #888;

SASS Variables allow you to define a value once and use it in multiple places. Variables begin with dollar signs and are set like CSS properties. You can change the value of the variable in one place, and all instances where it is used will be changed, too.


8. Which of the following directive allows you to generate styles in a loop?

a. @while
b. @if
c. @for
d. @each

Answer: c. @for

Explanation: The @for directive allows you to generate styles in a loop. The @for directive comes in two forms. The first option is @for $var from <start> through <end> which starts at <start> and loops "through" each iteration and ends at <end>. And the second option is @for $var from <start> to <end> which starts at <start> and loops through each iteration "to" <end> and stops. Once the directive hits the <end>, it stops the looping process and does not evaluate the loop that one last time.


9. The SassScript values can be taken as arguments in mixins, which is given when mixin is included and available as variable within the mixin.

a. True
b. False

Answer: a. True

Explanation: The above statement is true. The SassScript values can be taken as arguments in mixins, which is given when mixin is included and available as variable within the mixin. Mixins allow creating a group of styles, which are reusable throughout your stylesheet without any need to recreation of non-semantic classes.


10. What is the use of the @include directive in Sass?

a. Used to define the mixin.
b. Used to include the mixins in the document.
c. All of the above
d. None of the above

Answer: b. Used to include the mixins in the document.

Explanation: In Sass, the @include directive is used to include the mixins in the document. The styles defined by the mixin can be included into the current rule.


11. Who is the inventor of SASS?

a. Tim Berners-Lee
b. Guido van Rossum
c. Hakon Wium Lie
d. Hampton Catlin

Answer: d. Hampton Catlin

Explanation: Hampton Catlin is the inventor of SASS. Catlin created a style sheet language to expand on Cascading Style Sheets (CSS), used to describe presentation semantics of web pages. Later, he continued to work on Sass. Now, Sass is bundled as part of Rails.


12. Which directive is used to define the mixin?

a. @include
b. @mixin
c. @extend
d. @debug

Answer: b. @mixin

Explanation: The @mixin directive is used to define the mixin. This directive includes optionally the variables and argument after the name of the mixin.