Top 50 Syntactically Awesome Style Sheets (SASS) Interview Questions You Must Prepare 19.Mar.2024

You can perform boolean operations on Sass script by using and, or and not operators.

It directly takes the filename to import and all the imported files will get combined in a single CSS file.

  • It is pre-processing language which provides indented syntax (its own syntax) for CSS.
  • It allows writing code more efficiently and easy to maintain.
  • It is super set of CSS which contains all the features of CSS and is an open source pre-processor, coded in Ruby.
  • It provides document style in good structure format than flat CSS.
  • It uses re-usable methods, logic statements and some of the built in functions such as color manipulation, mathematics and parameter lists.

  • It allows writing clean CSS in a programming construct.
  • It helps in writing CSS quicker.
  • It is superset of CSS which helps designers and developers work more efficiently and quickly.
  • As Sass is compatible with all versions of CSS, we can use any available CSS libraries.
  • It is possible to use nested syntax and useful functions such as color manipulation, mathematics and other values.

There are two types of mixin arguments:

  • Keyword Arguments
  • Variable Arguments

Nested style is default styling of SASS. This way of styling is very useful when you are dealing with large CSS files.

You can set default values for variables by adding !default flag to the end of the variable value. It will not re-assign the value, if it is already assigned to the variable.

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

  • It is more stable, powerful and compatible with versions of CSS.
  • It is super set of CSS and is based on the JavaScript.
  • It is known as syntactic sugar for CSS which means it makes easier way for user to read or express the things more clearly.
  • It uses its own syntax and compiles to readable CSS.
  • You can easily write CSS in less code within less time.
  • It is an open source pre-processor which is interpreted into CSS.

In @each directive, a variable is defined which contains the value of each item in a list.

  • First it checks for Unicode byte, next @charset declaration and then Ruby string encoding.
  • Next if nothing is set, then it considers charset encoding as UTF-@
  • Determine character encoding explicitly by using @charset declaration. Just use "@charset encoding name" at the beginning of the stylesheet and SASS will assume that this is the given character encoding.
  • If output file of SASS contains non ASCII characters, then it will use the @charset declaration.

SASS supports placeholder selector using class or id selector. In normal CSS, these are specified with "#" or ".", but in SASS they are replaced with "%".

It allows for mathematical operations such as addition, subtraction, multiplication and division.

There are 5 types of operations:

  • Number Operations
  • Color Operations
  • String Operations
  • Boolean Operations
  • List Operations

Nesting is combining of different logic structures. Using SASS, we can combine multiple CSS rules within one another. If you are using multiple selectors, then you can use one selector inside another to create compound selectors.

It is used to selectively execute the code statements based on the result of the evaluating an expression.

You can select the parent selector by using the & character. It tells where the parent selector should be inserted.

Compact CSS style competitively takes less space than Expanded and Nested. It focuses mainly on selectors rather than its properties.

It allows using color components along with arithmetic operations.

Parentheses is pair of signs which are usually marked off by round brackets ( ) or square brackets [] which provides symbolic logic that affect the order of operations.

It displays the SassScript expression value as fatal error.

The CSS file that the SASS generates consists of default CSS style which reflects the structure of document. The default CSS styling is good but might not be suitable for all situations.

CSS properties can be declared in two ways −

  • Properties can be declared similar to CSS but without semicolon(;).
  • colon(:) will be prefixed to every property name.

SASS (Syntactically Awesome Stylesheet) is a CSS pre-processor which helps to reduce repetition with CSS and saves time. It is more stable and powerful CSS extension language that describes style of document cleanly and structurally.

In expanded output styling, each property and rule has its own line. It takes more space compared to nested CSS style.

It detects the errors and display the SassScript expression values to the standard error output stream.

You can use = for @mixin directive and + for @include directive which requires less typing and makes your code simpler, and easier to read.

Comments take up entire line and enclose all the text nested under them and they are line-based in indented syntax.

  • It takes time for developer to learn new features present in this pre-processor.
  • If more number of people working on the same site, then will use the same preprocessor. Some people use the Sass and some people use the CSS to edit the files directly. So it will become difficult to work with site.
  • There are chances of losing benefits of browser's built-in element inspector.

It provides SassScript variables in selectors and property names using #{ } syntax. You can specify variables or property names within the curly braces.

Using function directive, you can create your own function and use them in your script context or can be used with any value.

It is used to define the mixins that includes optionally the variables and argument after the name of the mixin.

It set style rule to different media types.

SassScript supports seven main data types:

  • Numbers (1, 5, 10)
  • Strings of texts ("foo", "bar")
  • Colors (blue, #04a3f9)
  • Booleans (true or false)
  • Nulls (null)
  • List of values, separated by space or commas (1.5em, Arial, Helvetica)
  • Maps from one value to another ( (key 1: value1, key 2: Value 2) )

It allows you to generate styles in a loop. The counter variable is used to set the output for each iteration.

You can use SASS in three different ways:

  • As a command line tool
  • As a Ruby module
  • As a plugin for Rack enable framework

The @else if statements are used with the @if directive, whenever the @if statement fails then the @else if statements are tried and if they also fails then the @else is executed.

It is a collection of nested rules which is able to make style block at root of the document.

  • It uses indentation rather than { and } to delimit blocks.
  • To separate statements, it uses newlines instead of semicolons(;).
  • Property declaration and selectors must be placed on its own line and statements within { and } must be placed on new line and indented.

Compressed CSS style takes least amount of space compared to all other styles. It provides whitespaces only to separate selectors and newline at the end of the file.

It is used to share rules and relationships between selectors. It can extend all another class styles in one class and can also apply its own specific styles.

It is used to include arguments in the mixins. The arguments which are named can be passed in any order and the default values of argument can be omitted.

Variable arguments are used to pass any number of arguments to mixin. It contains keyword arguments passed to the function or mixin.

SASS supports two syntaxes namely SCSS and Indented syntax.

  • The SCSS (Sassy CSS) is an extension of CSS syntax that makes much easier to maintain large stylesheets and can recognize vendor specific syntax and many CSS. SCSS files use the extension .scss.
  • The Indented is an older syntax and sometimes just called as Sass. Using this form of syntax, CSS can be written concisely. SASS files use the extension .sass.

It evaluates SassScript expression using command line. You can run the shell with the sass command line along with -i option.

Sass supports two types of comments −

  • Multiline comments − These are written using /* and */. Multiline comments are preserved in CSS output.
  • Single line comments − These are written using // followed by comments. single line comments are not preserved in CSS output.

It is used to include the mixin in the document and styles defined by the mixin can be included into the current rule.

Lists represent series of values which are separated using commas or space.