Media queries work in LESS exactly as they do in CSS, with one major convenience: LESS lets you nest an @media block directly inside a selector, keeping responsive overrides next to the base styles they affect.
How LESS Handles @media
@media is native CSS syntax, LESS doesn't reinvent it. What LESS adds is the ability to write a media query nested inside a selector's braces; the compiler automatically hoists it out to the top level of the compiled CSS.
Because @media conditions are just strings, LESS variables and interpolation can also be used to build a query dynamically, which becomes especially useful once breakpoints are stored as shared variables.
@media (min-width: 768px) and (orientation: landscape)
Standard CSS media logic
Variable-driven query
@media ~"(min-width: @{bp})"
Embeds a LESS variable into the condition
Print media
@media print { }
Works identically, nested or top-level
Why Nesting Helps Maintainability
Writing responsive overrides directly next to their base declaration keeps a single component's full responsive behavior in one place, rather than scattered across separate top-level media query blocks at the bottom of a file.
Storing a breakpoint value as a variable and embedding it into an escaped media condition string keeps every query referencing the same source of truth, this pattern is expanded fully in the Breakpoints lesson.
The tilde escape lets LESS interpolate @bp-tablet into the condition string without misparsing the parentheses.
Combining Multiple Media Conditions
Standard CSS media logic, and, comma-separated alternatives, and not, all work identically inside a LESS-nested @media block, since LESS passes the condition through largely as-is.
Assuming a nested @media block stays physically nested in the compiled CSS; LESS always hoists it to the top level.
Forgetting the tilde escape when embedding a variable into a media condition, causing a parse error on the parentheses.
Writing the same breakpoint value as a raw number in multiple places instead of a shared variable.
Nesting so many separate media queries inside one selector that the overall responsive behavior becomes hard to scan.
Key Takeaways
@media in LESS is native CSS syntax; LESS only adds the ability to nest it inside a selector.
Nested media queries are automatically hoisted to the top level of the compiled CSS.
Variables can be embedded into a media condition using an escaped string with interpolation.
Combine nested media queries with standard CSS logical operators exactly as you would in plain CSS.
Pro Tip
Nest a component's responsive overrides directly inside that component's selector rather than collecting all media queries in one large block at the end of the file, it keeps each component's full responsive behavior readable in one place.
You now understand how LESS handles media queries. Next, learn how to build reusable responsive mixins.