Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9171039
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T16:06:32+00:00 2026-06-17T16:06:32+00:00

I have the following LESS: .container { .column, .columns { .one& { width: 40px;

  • 0

I have the following LESS:

.container {
    .column, .columns {
        .one& {
            width: 40px;
        }
    }
}

When I compile I’m getting the following for my CSS:

.one.container .column,
.one.container .columns {
    width: 40px;
}

But I expected to get:

.container .one.column,
.container .one.columns {
    width: 40px;
}

It appears the parent operator (&) in LESS is actually referencing what I’d expect to be the grandparent. Am I nesting things properly? The docs don’t show any examples of nesting more than one level deep. Can I achieve my desired output with nesting?

I’m using lessc 1.3.3 installed via npm.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T16:06:33+00:00Added an answer on June 17, 2026 at 4:06 pm

    It’s important to think of & as more of a “parentage” combinator, rather than a “parent” combinator. That is, it takes the whole nested string of selectors up to that point (no matter how many levels deep) and acts as the equivalent of a string replacement holder. So with a reduced version of your example…

    .container {
        .column {
            .one& {
                width: 40px;
            }
        }
    }
    

    …the selector string at that level is .container .column. This is what is “replaced” in the position of the &, so when you concatenate to the beginning as you do above, it gets attached at the beginning of the whole selector string and you end up with your:

    .one.container .column {width 40px;}
    

    But if you concatenate from the end (no space between & and .) then…

    .container {
        .column {
            &.one {
                width: 40px;
            }
        }
    }
    

    …becomes:

    .container .column.one {width 40px;}
    

    This last one is really the class combination you want, though just not quite in the same order you were hoping for. But order does not matter to the browser, .one.column or .column.one are the same, it just means an element that has both individual classes applied to it like so:

    <div class="column one"></div>
    <div class="one column"></div>
    

    Both of those are equivalent, and either .one.column or .column.one as a selector is going to select both elements, because both elements have both classes.

    If order is absolutely vital to you (you just must have your generated CSS be as you are seeking), then you would need to do a bit of repetition like this:

    .container {
        .column {
           ...generic column code here...
        }
        .one {
            &.column {
                width: 40px;
                ...any other code dependent on combination of .one.column here...
            }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following less.css ( http://lesscss.org/ ): #content { overflow: hidden; width: 100%;
I have a following css #container { border:1px solid black; } #container #header {
I have multiple <div> tag with same width but different height in a container.
I have the following code in a c++ listener class (more or less), which
I have a varchar column which contains date in following format dd/mm/yyyy I need
I have inherited the following CSS for a site, and I can't tell if
I have 2 tables: A and B A contains the following columns: Id [uniqueIdentifier]
I'm trying to have the following markup: body #container #content where body is full
I have following plist: <?xml version=1.0 encoding=UTF-8?> <!DOCTYPE plist PUBLIC -//Apple//DTD PLIST 1.0//EN http://www.apple.com/DTDs/PropertyList-1.0.dtd>
I have following source. In insertMessage(..), it calls selectMessage to check whether duplicate record

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.