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 nameDescription
hueIn HSL color space, the hue channel is extracted off the color object.
saturationIn HSL color space, the saturation channel is extracted off the color object.
lightnessIn HSL color space, the lightness channel is extracted off the color object.
hsvhueIn HSV color space, the hue channel is extracted off the color object.
hsvsaturationIn HSL color space, the saturation channel is extracted off the color object.
hsvvalueIn HSL color space, the value channel is extracted off the color object.
redThe red channel is extracted off the color object.
greenThe green channel is extracted off the color object.
blueThe blue channel is extracted off the color object.
alphaThe alpha channel is extracted off the color object.
lumaluma value is calculated off a color object.
luminanceThe 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 OptionsDescription
referenceIt uses a LESS file only as reference and will not output it.
inlineIt enables you to copy your CSS into the output without being processed.
lessIt will treat the imported file as the regular LESS file, despite whatever may be the file extension.
cssIt will treat the imported file as the regular CSS file, despite whatever may be the file extension.
onceIt will import the file only one time.
multipleIt will import the file multiple times.
optionalIt continues compiling even though the file to import is not found.