LESS interviews cover preprocessor fundamentals—variables, mixins, and imports—and how LESS compares to Sass in legacy codebases.
LESS Interview Overview
LESS extends CSS with variables (@primary), mixins, nesting, functions, and imports that merge at compile time. Understand client-side less.js vs build-time compilation and why production always precompiles CSS.
Interviewers may ask about migration to Sass or PostCSS, guarding mixin parametric patterns, and avoiding duplicated output when mixins inline vs classes extend. Know where LESS still appears (Bootstrap 3 era, older enterprise themes).
LESS Interview Cheatsheet
Quick answers you can expand in a real interview.
Topic
Short answer
Variable syntax
@variable-name: value;
Parametric mixin
.border-radius(@r: 5px) { ... }
Import partials
@import "variables.less";
Escape calc
height: calc(100% ~"-" 20px);
Guard mixin
.mixin(@x) when (@x > 10) { ... }
Compile CLI
lessc styles.less styles.css
15 LESS Interview Questions with Answers
Use the short version first, then offer trade-offs if the interviewer wants depth.
1. What is LESS and why was it popular?
LESS is a CSS preprocessor adding variables, mixins, nesting, and functions with JavaScript-like syntax. It gained traction with Bootstrap 2/3 and allowed client-side compilation via less.js in browsers during prototyping. Build-time lessc is standard for production today.
2. How do LESS variables work?
Variables use @name: value; syntax and are compile-time like Sass—replaced in output CSS. They scope lexically in blocks unless declared lazy-wide. LESS 3+ supports optional lazy evaluation. They do not cascade at runtime like CSS custom properties.
3. Explain mixins in LESS.
Any class or ruleset can act as a mixin: .border-radius(@r: 4px) { border-radius: @r; } then .btn { .border-radius(8px); } inlines rules into .btn output. Parametric mixins accept defaults. Mixins can be guarded with when conditions for responsive or theme variants.
4. Difference between LESS and Sass for a team choosing preprocessors?
Sass (SCSS) has richer module system (@use), wider ecosystem, and Dart Sass maintenance. LESS syntax feels closer to CSS with @vars and is simpler but less feature-rich for large design systems. Greenfield projects usually pick Sass or native CSS; LESS skills matter for legacy maintenance.
5. What is client-side LESS compilation and why avoid it in production?
less.js in the browser fetches .less files and compiles on the fly—convenient for demos but slow, flash-of-unstyled-content prone, and exposes source structure. Production pipelines use lessc, Webpack less-loader, or Grunt/Gulp tasks to emit minified CSS ahead of time.
6. How do imports work in LESS?
@import "file.less" merges files into one compilation unit—variables and mixins become globally visible unlike Sass @use namespacing. Optional (inline) imports embed raw CSS or external URLs. Over-importing creates large bundles; split entry points for code splitting where supported.
7. What are LESS functions and color manipulation?
Built-in functions adjust colors: darken(@blue, 10%), lighten, fade, mix. Math operations work on numbers with units when compatible. Functions run at compile time—output is static hex/rgb in CSS. Document token math so designers predict resulting colors.
8. Explain nesting in LESS and specificity pitfalls.
Nesting mirrors Sass: .nav { a { color: @link; &:hover { ... } } } compiles to .nav a and .nav a:hover. Deep nesting raises specificity and couples styles to HTML shape. Flat class naming (BEM) often outlasts nested LESS in large apps.
9. What is & parent selector reference?
& refers to the current selector parent when nesting—used for pseudo-classes (&:hover), modifiers (&--large), and concatenation (&-icon). Misusing & for BEM without understanding compiled output creates unexpected selectors.
10. How do guarded mixins work?
Patterns like .text-emphasis(@color) when (iscolor(@color)) apply only when conditions match—useful for theme loops and responsive breakpoints. Guards replace some if/else logic at compile time without runtime cost.
11. LESS extend vs mixin output differences?
Mixins copy declarations into the caller—can duplicate CSS. LESS also supports extend-like grouping in some patterns but mixins are primary. Heavy mixin use inflates file size; extract shared classes when duplication crosses a threshold.
12. How would you integrate LESS with Webpack?
Use less-loader chaining css-loader and style-loader or MiniCssExtractPlugin. Pass modifyVars for theme overrides at build time. Enable source maps in development. PostCSS autoprefixer often runs after LESS compilation in the pipeline.
13. What are common migration paths off LESS?
Teams migrate to SCSS module architecture, CSS-in-JS, or native CSS with PostCSS. Automated converters handle variables and nesting partially; manual pass fixes mixin guards and imports. Prioritize high-churn components first and run visual regression tests.
14. How does Bootstrap relate to LESS historically?
Bootstrap 3 was authored in LESS with a parallel Sass port. Many enterprise apps still carry Bootstrap 3 LESS variables (@brand-primary). Understanding LESS helps maintain those themes even if new work uses Bootstrap 5 with Sass or vanilla CSS variables.
15. Compare compile-time preprocessors to CSS custom properties.
LESS variables resolve at build—fine for static themes. CSS custom properties cascade and update at runtime—required for user-controlled themes and dark mode without recompilation. Hybrid approaches compile token names to var(--token) in output CSS.
Common Mistakes
Shipping less.js client compilation to production users.
Global @import sprawl without modular organization.
Deep nesting that breaks override strategies later.
Expecting LESS variables to update dynamically in the browser.
Key Takeaways
Know @variables, parametric mixins, and guarded patterns.
Always precompile LESS for production performance.
Contrast LESS with Sass modules and modern native CSS.
Frame LESS as valuable for legacy Bootstrap-era maintenance.
Pro Tip
If asked Sass vs LESS, emphasize Sass module system and ecosystem—then show you can read LESS confidently in legacy repos.
You now have 15 LESS interview questions with answers. Continue with the quiz to reinforce the topics.