Sass | |
Designer: | Hampton Catlin |
Developer: | Natalie Weizenbaum, Chris Eppstein |
Typing: | Dynamic |
Implementations: | Dart |
Influenced: | Less, Stylus, Tritium, Bootstrap (v4+) |
License: | MIT License |
Latest Release Version: | 1.75.0[1] |
Influenced By: | CSS (both "indented" and SCSS)YAML and Haml (indented syntax)Less (SCSS) |
Operating System: | Cross-platform |
File Ext: | .sass, .scss |
Sass (short for syntactically awesome style sheets) is a preprocessor scripting language that is interpreted or compiled into Cascading Style Sheets (CSS). SassScript is the scripting language itself.
Sass consists of two syntaxes. The original syntax, called "the indented syntax," uses a syntax similar to Haml.[2] 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.[3]
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.[4]
The indented syntax is a metalanguage. SCSS is a nested metalanguage and a superset of CSS, as valid CSS is valid SCSS with the same semantics.
SassScript provides the following mechanisms: variables, nesting, mixins,[5] and selector inheritance.
Sass was initially designed by Hampton Catlin and developed by Natalie Weizenbaum.[6] [7]
SassScript was implemented in multiple languages, the noteworthy implementations are:
Sass allows variables to be defined. Variables begin with a dollar sign ($
). Variable assignment is done with a colon (:
).
SassScript supports four data types:
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.
CSS does support logical nesting, but the code blocks themselves are not nested. Sass allows the nested code to be inserted within each other.
More complicated types of nesting including namespace nesting and parent references are discussed in the Sass documentation.
Sass allows for iterating over variables using, and, which can be used to apply different styles to elements with similar classes or ids.
Mixins also support arguments.
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.
Sass supports multiple inheritance.
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:
IDE | Software | |
---|---|---|
Adobe Dreamweaver CC 2017 | ||
Eclipse | ||
Emacs | sass-mode | |
JetBrains IntelliJ IDEA (Ultimate Edition) | ||
JetBrains WebStorm | ||
Mindscape | ||
Microsoft Visual Studio | SassyStudio | |
NetBeans | ||
Vim | haml.zip | |
Atom | ||
Visual Studio Code | ||
Sublime | ||
Edit+ |