3

In Sass, is there any way to use root/top-level selectors inside a nested element? This would be useful.

For example, I want to define the same style for all root-level a tags and li tags only inside ul. Here's a imaginary example where / accomplishes this:

ul {
    li, /a {
       color:black;
    }
}

The rendered stylesheet would then look like this:

a {
    color: black;
}

ul li {
    color: black;
}

2 Answers 2

0

You could use selective inheritance using @extend. HTH.

0

This file.scss

ul {
  li,
  li a {
    color:black
  }
}

Will compile to this

ul li,
ul li a {
  color: black;
}

Isn't that what you wanted?


UPDATE: What you're trying to achieve is possible with @extend

1
  • Your example still renders a nested object. I updated my question to display what kind of output is desired.
    – dhulihan
    Feb 19, 2013 at 21:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.