Questions tagged [sass]

Sass (Syntactically Awesome Style Sheets) is an extension of CSS adding features like nested rules, variables, mixins and class extensions. This enables developers to write structured, manageable and reusable CSS. Sass is compiled into standard CSS. It is primarily a CSS pre-processor language that accepts both the CSS and its personalised syntax of writing visual design codes.

Overview:

Sass is a meta-language on top of that describes the style of a document cleanly and structurally, with more power than flat CSS allows.

Sass is an extension of written in . It adds nested rules, variables, mixins, selector inheritance, and useful functions like color manipulation or conditional statements2. It's translated to well-formatted, standard CSS using the command-line tool or a web-framework plugin.

It is the only language that can store design tokens (e.g. colors, font sizes, spacing) and use the value types9 natively; i.e. numbers, colors, strings, lists, and booleans.

Sass has two syntaxes:

  1. SCSS (Sassy CSS): As of Sass3, this is the main syntax. It is a superset of CSS3, so all valid CSS files are also valid SCSS. Files with this syntax have the extension .scss.

Example SCSS:

$margin: 12px;

li {
  .border {
    margin: $margin / 2;
  }
}
  1. SASS: The indented syntax. Instead of braces and semicolons, it uses line indentation to specify blocks (similar to Ruby's syntax). Files with this syntax have the extension .sass.

Example SASS:

$margin: 12px

li
  .border
    margin: $margin / 2

Frameworks / Extensions:

  • 4 is an extension of Sass which provides pre-defined cross-browser mixins and additional functionality like automated sprite-generation.
  • 5 is a simple and lightweight mixin library for Sass.

Flavors:

  • Ruby Sass1 is the original Ruby-based version of Sass.
  • LibSass6 is C/C++ port of the Sass precompiler. It compiles very quickly, can be embedded in other languages and binaries, and aims for feature parity with the original Ruby Sass.
  • Node Sass7 uses LibSass to compile .scss files using Node.

Links:


Resources:

27250 questions
113
votes
3 answers

How to integrate CSS pre-processing within Eclipse?

I would like to edit SCSS files in Eclipse, preferably with syntax highlighting for .scss files. I found these resources valuable: http://sass-lang.com/editors.html - has no editor for .scss files only…
Eric H
  • 1,676
  • 3
  • 16
  • 18
112
votes
4 answers

Is it possible in SASS to inherit from a class in another file?

The question pretty much says it all. For instance, if I were using, say, Twitter Bootstrap, could I define classes in my own SASS stylesheet that inherit from Bootstrap's CSS classes? Or does inheritance in SASS only work within the scope of a…
Dan Tao
  • 125,917
  • 54
  • 300
  • 447
112
votes
5 answers

What does !default in a css property value mean?

The twitter bootstrap code has a lot of CSS properties with a !default at the end. E.g. p { color: white !default; } What does !default do? UPDATE My bad for not being clear. I am using the SASS part of Bootstrap.
Coffee Bite
  • 4,956
  • 5
  • 33
  • 38
111
votes
5 answers

Sass combining parent using ampersand (&) with type selectors

I am having trouble with nesting in Sass. Say I have the following HTML:

Text

Text

Link When I try to nest my styles in the following I get a compiling…
McShaman
  • 3,627
  • 8
  • 33
  • 46
108
votes
4 answers

How to compile or convert sass / scss to css with node-sass (no Ruby)?

I was struggling with setting up libsass as it wasn't as straight-forward as the Ruby based transpiler. Could someone explain how to: install libsass? use it from command line? use it with task runners like gulp and grunt? I have little experience…
Thoran
  • 8,884
  • 7
  • 41
  • 50
108
votes
5 answers

Modify file in place (same dest) using Gulp.js and a globbing pattern

I have a gulp task that is attempting to convert .scss files into .css files (using gulp-ruby-sass) and then place the resulting .css file into the same place it found the original file. The problem is, since I'm using a globbing pattern, I don't…
Dan-Nolan
  • 6,594
  • 4
  • 27
  • 32
105
votes
7 answers

Using SASS with ASP.NET

I'm looking into ways to use SASS (Syntactically Awesome StyleSheets) from the Ruby HAML package in an ASP.NET environment. Ideally, I would like compilation of SASS files into CSS to be a seamless part of the build process. What are the best ways…
Guðmundur H
  • 11,478
  • 3
  • 24
  • 22
105
votes
14 answers

When using SASS how can I import a file from a different directory?

In SASS, is it possible to import a file from another directory? For example, if I had a structure like this: - root_directory - sub_directory_a - _common.scss - template.scss - sub_directory_b -…
spaaarky21
  • 6,524
  • 7
  • 52
  • 65
105
votes
8 answers

Sass or Compass without ruby?

Is there a way to use Sass or Compass or anything like that without Ruby? I have been looking around google and this site and can't find anything, any help would be appreciated. Thank you
Troy Cosentino
  • 4,658
  • 9
  • 37
  • 59
101
votes
5 answers

Using @include vs @extend in Sass?

In Sass, I can't quite discern the difference between using @include with a mixin and using @extend with a placeholder class. Don't they amount to the same thing?
temporary_user_name
  • 35,956
  • 47
  • 141
  • 220
100
votes
7 answers

Sass/Compass - Convert Hex, RGB, or Named Color to RGBA

This may be Compass 101, but has anyone written a mixin which sets the alpha value of a color? Ideally, I would like the mixin to take any form of color definition, and apply transparency: @include set-alpha( red, 0.5 ); //prints rgba(255,…
Pat Newell
  • 2,219
  • 2
  • 18
  • 23
100
votes
3 answers

Does LESS have an "extend" feature?

SASS has a feature called @extend which allows a selector to inherit the properties of another selector, but without copying the properties (like mixins). Does LESS have this feature as well?
jonschlinkert
  • 10,872
  • 4
  • 43
  • 50
99
votes
3 answers

How do you define attribute selectors in SASS?

In CSS, you can do this: input[type=submit] { // properties } It's a very useful for styling form buttons. How do you do the same thing in SASS?
Craig Walker
  • 49,871
  • 54
  • 152
  • 212
98
votes
7 answers

Global scss variables for Angular components without importing them everytime

I do already have SCSS variables defined in src/styles/settings/_variables.scss and I am importing them into src/styles.scss, but still these variables aren't available for every single component. Is there any way to make a global file which holds…
Volodymyr Humeniuk
  • 3,411
  • 9
  • 35
  • 70
97
votes
1 answer

Sass - two classes in a single tag

So, i need a style for .question_actions.active my existing CSS .question_actions { float: right; font-size: 1em; width: 110px; } .question_action { margin-bottom: 8px; padding: 3px; } .question_actions.active { /* some…
meow
  • 27,476
  • 33
  • 116
  • 177