”;
Dear readers, these SASS Interview Questions have been designed specially to get you acquainted with the nature of questions you may encounter during your interview for the subject of SASS. As per my experience good interviewers hardly plan to ask any particular question during your interview, normally questions start with some basic concept of the subject and later they continue based on further discussion and what you answer −
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.
-
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 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.
-
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.
-
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.
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.
You can use SASS in three different ways −
-
As a command line tool
-
As a Ruby module
-
As a plugin for Rack enable framework
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.
You can select the parent selector by using the & character. It tells where the parent selector should be inserted.
SASS supports placeholder selector using class or id selector. In normal CSS, these are specified with “#” or “.“, but in SASS they are replaced with “%“.
There are 5 types of operations −
-
Number Operations
-
Color Operations
-
String Operations
-
Boolean Operations
-
List Operations
It allows for mathematical operations such as addition, subtraction, multiplication and division.
It allows using color components along with arithmetic operations.
Lists represent series of values which are separated using commas or space.
You can perform boolean operations on Sass script by using and, or and not operators.
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 provides SassScript variables in selectors and property names using #{ } syntax. You can specify variables or property names within the curly braces.
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.
It directly takes the filename to import and all the imported files will get combined in a single CSS file.
It set style rule to different media types.
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 is a collection of nested rules which is able to make style block at root of the document.
It is used to selectively execute the code statements based on the result of the evaluating an expression.
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 allows you to generate styles in a loop. The counter variable is used to set the output for each iteration.
In @each directive, a variable is defined which contains the value of each item in a list.
It is used to define the mixins that includes optionally the variables and argument after the name of the mixin.
It is used to include the mixin in the document and styles defined by the mixin can be included into the current rule.
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.
There are two types of mixin arguments −
-
Keyword Arguments
-
Variable Arguments
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.
Using function directive, you can create your own function and use them in your script context or can be used with any value.
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.
Nested style is default styling of SASS. This way of styling is very useful when you are dealing with large CSS files.
In expanded output styling, each property and rule has its own line. It takes more space compared to nested CSS style.
Compact CSS style competitively takes less space than Expanded and Nested. It focuses mainly on selectors rather than its properties.
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 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.
-
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.
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.
You can use = for @mixin directive and + for @include directive which requires less typing and makes your code simpler, and easier to read.
sass –watch C:rubylibsassstyle.scss:style.css
Comments take up entire line and enclose all the text nested under them and they are line-based in indented syntax.
sass input.scss output.css
-
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-8.
-
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 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 evaluates SassScript expression using command line. You can run the shell with the sass command line along with –i option.
It detects the errors and display the SassScript expression values to the standard error output stream.
It displays the SassScript expression value as fatal error.
What is Next?
Further, you can go through your past assignments you have done with the subject and make sure you are able to speak confidently on them. If you are fresher then interviewer does not expect you will answer very complex questions, rather you have to make your basics concepts very strong.
Second it really doesn”t matter much if you could not answer few questions but it matters that whatever you answered, you must have answered with confidence. So just feel confident during your interview. We at tutorialspoint wish you best luck to have a good interviewer and all the very best for your future endeavor. Cheers 🙂
”;