This cheat sheet condenses the most important syntax and patterns from every lesson in this course into one fast, scannable reference you can return to while building real projects.
How to Use This Cheat Sheet
Each table below groups related LESS syntax together, variables and imports, mixins and guards, functions, and selectors, so you can quickly jump to the category you need without re-reading full lessons.
Variables (@name), nesting with &, and @import form the foundation of everyday LESS.
Mixins accept parameters with defaults; guards use when for conditional logic.
There is no @if/@else; guarded mixin definitions replace conditional statements entirely.
Refer back to the individual lessons in the sidebar for deeper explanations of any row below.
Variables, Imports, and Nesting
Core syntax for declaring values and loading files.
Feature
Syntax
Notes
Variable
@name: value;
Compile-time only, not a CSS custom property
Variable variable
@@name
Looks up a variable by a dynamically stored name
Import
@import "file";
Inlines another .less file at compile time
Reference import
@import (reference) "file";
Loads without unused standalone output
Nesting
.a { .b { ... } }
Compiles to .a .b
Parent selector
&:hover, &.active, &-icon
References the enclosing selector
Mixins and Guards
Reference for defining, calling, and conditionally branching mixins.
Feature
Syntax
Notes
Define a mixin
.name() { ... }
Parentheses suppress standalone output
Call a mixin
.name();
Copies declarations into the caller
Default parameter
.box(@size: 10px) { }
Optional at the call site
Semicolon args
.font(@f; @s; @w);
Needed when an argument is a comma list
Guard
.m(@a) when (@a > 0) { }
Conditional mixin definition
Guard operators
>, >=, =, =<, <
No != or <= exist
Logical and/or/not
when (a) and (b), when (a), (b), when not (a)
Combine multiple conditions
Fallback case
when (default())
Runs only if no other guard matched
Namespace call
#bundle.mixin();
Access a mixin inside a namespace
Functions and Operations
Reference for math, color, string, and list functions.
Feature
Syntax
Notes
Math operation
@a + @b, @a * 2
Resolved at compile time
Rounding
round(), ceil(), floor()
Cleans up decimal results
Percentage
percentage(1/3)
33.333333%
Lighten/darken
lighten(@c, 10%), darken(@c, 10%)
Adjusts HSL lightness
Fade
fade(@c, 50%)
Sets absolute alpha transparency
Mix colors
mix(@a, @b, 50%)
Blends two colors
Escape string
~"raw text"
Bypasses further LESS processing
List length
length(@list)
Counts items in a list
Loop
each(range(4), { ... });
Iterates a generated numeric range
Selectors and Interpolation
Reference for BEM patterns, interpolation, and extend.
Feature
Syntax
Notes
BEM element
&__title
Compiles to .block__title
BEM modifier
&--large
Compiles to .block--large
Selector interpolation
.@{name} { }
Injects a variable into a selector
Property interpolation
@{prop}: value;
Injects a variable into a property name
Extend
&:extend(.other);
Merges selectors instead of duplicating
Extend all
&:extend(.other all);
Also matches compound selector usages
Common Mistakes
Trying to memorize this entire cheat sheet instead of using it as a fast lookup while actively building.
Copying a syntax pattern without adjusting variable and mixin names to match your actual project.
Forgetting that this condensed view omits edge cases covered in the full individual lessons.
Not bookmarking the official LESS documentation alongside this page for anything not covered here.
Key Takeaways
This cheat sheet condenses variables, imports, nesting, mixins, guards, and functions into one reference.
Use it as a fast lookup while building, not a replacement for understanding the underlying concepts.
Revisit the full lesson for any row when you need deeper context or edge-case handling.
The official LESS documentation remains the definitive source for anything not covered here.
Pro Tip
Bookmark this page alongside the official LESS documentation at lesscss.org, this cheat sheet covers the syntax you'll use in the vast majority of everyday work, while the official docs cover every remaining edge case.
Color Functions Reference
The most commonly used LESS color functions in one table.
Function
Example
Effect
lighten()
lighten(@c, 10%)
Increases HSL lightness
darken()
darken(@c, 10%)
Decreases HSL lightness
saturate()
saturate(@c, 20%)
Increases HSL saturation
desaturate()
desaturate(@c, 20%)
Decreases HSL saturation
fadein() / fadeout()
fadeout(@c, 10%)
Relative alpha adjustment
spin()
spin(@c, 30)
Rotates hue by degrees
contrast()
contrast(@c, #000, #fff)
Picks readable text color
red() / green() / blue()
red(@c)
Extracts a single RGB channel
Architecture and Responsive Reference
Common patterns for breakpoints, tokens, and folder structure.