LESS Interview Questions part 3
15. How can you invoke the compiler from the command line?
Answer:
You can invoke the compiler from the command line in LESS as,
$ lessc styles.less
This will output the compiled CSS to stdout; you may then redirect it to a file of your choice.
$ lessc styles.less > styles.css
16. What is the use of Escaping?
Answer:
Escaping builds selectors dynamically and uses property or variable value as arbitrary string.
It is used when proprietary syntax is not recognized by LESS.
17. What are the operations use in LESS?
Answer:
LESS uses some arithmetical operations like,
- Addition (+)
- Subtraction (-)
- Multiplication (*)
- Division (/)
These operations can be done on any number, color and variable.
Operations save lot of time when you are using variables and you feel like working on simple mathematics.
18. What is Data-URI in LESS?
Answer:
Data URI is an excellent way to reduce HTTP requests.
It allows developers to avoid external image referencing and instead embed them directly into a style sheet.
19. What is the use of Color Channel function in LESS?
Answer:
LESS supports few in-built functions which set value about a channel.
Color Channel functions are used to set value about a channel. The channel sets the value according to the color definition.
The HSL colors have hue, saturation and lightness channel and the RGB color have red, green and blue channel.
The following table lists out all the color channel functions.
Function name | Description |
---|
hue | In HSL color space, the hue channel is extracted off the color object. |
saturation | In HSL color space, the saturation channel is extracted off the color object. |
lightness | In HSL color space, the lightness channel is extracted off the color object. |
hsvhue | In HSV color space, the hue channel is extracted off the color object. |
hsvsaturation | In HSL color space, the saturation channel is extracted off the color object. |
hsvvalue | In HSL color space, the value channel is extracted off the color object. |
red | The red channel is extracted off the color object. |
green | The green channel is extracted off the color object. |
blue | The blue channel is extracted off the color object. |
alpha | The alpha channel is extracted off the color object. |
luma | luma value is calculated off a color object. |
luminance | The luma value is calculated without gamma correction. |
20. What is the use of import option in LESS?
Answer:
LESS offers the @import statement that allows the style sheets to import both LESS and CSS style sheets.
The following tables lists the import directives that will be implemented in the import statements.
Import Options | Description |
---|
reference | It uses a LESS file only as reference and will not output it. |
inline | It enables you to copy your CSS into the output without being processed. |
less | It will treat the imported file as the regular LESS file, despite whatever may be the file extension. |
css | It will treat the imported file as the regular CSS file, despite whatever may be the file extension. |
once | It will import the file only one time. |
multiple | It will import the file multiple times. |
optional | It continues compiling even though the file to import is not found. |