Sass consists of two syntaxes. The original syntax, called "the indented syntax," uses a syntax similar to Haml.[2][3] It uses indentation to separate code blocks and newline characters to separate rules. The newer syntax, SCSS (Sassy CSS), uses block formatting like that of CSS. It uses braces to denote code blocks and semicolons to separate rules within a block. The indented syntax and SCSS files are traditionally given the extensions .sass and .scss, respectively.[4]
CSS3 consists of a series of selectors and pseudo-selectors that group rules that apply to them. Sass (in the larger context of both syntaxes) extends CSS by providing several mechanisms available in more traditional programming languages, particularly object-oriented languages, but that are not available to CSS3 itself. When SassScript is interpreted, it creates blocks of CSS rules for various selectors as defined by the Sass file. The Sass interpreter translates SassScript into CSS. Alternatively, Sass can monitor the .sass or .scss file and translate it to an output .css file whenever the .sass or .scss file is saved.[5]
The official "sass" node module on npm, which is Dart Sass compiled to pure JavaScript.[9]
The official "sass-embedded" node module which is a JavaScript wrapper around the native Dart executable.[10]
The original open-sourceRuby implementation created in 2006,[8] since deprecated due to the lack of maintainers and reached End-of-Life in March 2019.[11][12]
libSass, the official open-source C++ implementation, deprecated in October 2020.[13]
The deprecated "node-sass" node module on npm, based on the deprecated libSass.[14]
JSass, an unofficial Java implementation,[15] based on the deprecated libSass.[16]
phamlp, an unofficial Sass/SCSS implementation in PHP.[8]
Firebug, a FirefoxXUL ("legacy") extension for web development.[18] It has been since deprecated in favor of developer tools integrated into Firefox itself. It stopped working since Firefox 57 dropped support for XUL extensions.
Features
Variables
Sass allows variables to be defined. Variables begin with a dollar sign ($). Variable assignment is done with a colon (:).[18]
Variables can be arguments to or results from one of several available functions.[19] During translation, the values of the variables are inserted into the output CSS document.[2]
Sass allows for iterating over variables using @for, @each and @while, which can be used to apply different styles to elements with similar classes or ids.
While CSS3 supports the Document Object Model (DOM) hierarchy, it does not allow selector inheritance. In Sass, inheritance is achieved by inserting a line inside of a code block that uses the @extend keyword and references another selector. The extended selector's attributes are applied to the calling selector.[2]
At the 2012 HTML5 Developer Conference, Hampton Catlin, the creator of Sass, announced version 1.0 of libSass, an open source C++ implementation of Sass developed by Catlin, Aaron Leung, and the engineering team at Moovweb.[20][21]
According to Catlin, libSass can be "drop[ped] into anything and it will have Sass in it...You could drop it right into Firefox today and build Firefox and it will compile in there. We wrote our own parser from scratch to make sure that would be possible."[22]
The design goals of libSass are:
Performance – Developers have reported 10x speed up increases over the Ruby implementation of Sass.[23]
Easier integration – libSass makes it easier to integrate Sass into more software. Before libSass, tightly integrating Sass into a language or software product required bundling the entire Ruby interpreter. By contrast, libSass is a statically linkable library with zero external dependencies and C-like interface, making it easy to wrap Sass directly into other programming languages and tools. For example, open source libSass bindings now exist for Node, Go, and Ruby.[21]
Compatibility – libSass's goal is full compatibility with the official Ruby implementation of Sass. This goal has been achieved on libsass 3.3.[24]