Sass (short for ''syntactically awesome style sheets'') is a
preprocessor scripting language
A scripting language or script language is a programming language that is used to manipulate, customize, and automate the facilities of an existing system. Scripting languages are usually interpreted at runtime rather than compiled.
A scripting ...
that is
interpreted or
compiled
In computing, a compiler is a computer program that translates computer code written in one programming language (the ''source'' language) into another language (the ''target'' language). The name "compiler" is primarily used for programs that ...
into
Cascading Style Sheets
Cascading Style Sheets (CSS) is a style sheet language used for describing the presentation of a document written in a markup language such as HTML or XML (including XML dialects such as SVG, MathML or XHTML). CSS is a cornerstone techno ...
(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.
It uses
indentation to separate
code blocks and
newline
Newline (frequently called line ending, end of line (EOL), next line (NEL) or line break) is a control character or sequence of control characters in character encoding specifications such as ASCII, EBCDIC, Unicode, etc. This character, or a ...
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
Extension, extend or extended may refer to:
Mathematics
Logic or set theory
* Axiom of extensionality
* Extensible cardinal
* Extension (model theory)
* Extension (predicate logic), the set of tuples of values that satisfy the predicate
* Ex ...
.sass and .scss, respectively.
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 language
A programming language is a system of notation for writing computer programs. Most programming languages are text-based formal languages, but they may also be graphical. They are a kind of computer language.
The description of a programming ...
s, particularly
object-oriented languages
Object-oriented programming (OOP) is a programming paradigm based on the concept of "Object (computer science), objects", which can contain data and Computer program, code. The data is in the form of Field (computer science), fields (often kno ...
, 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.
[Sass - Syntactically Awesome Stylesheets](_blank)
Tutorial
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
Semantics (from grc, σημαντικός ''sēmantikós'', "significant") is the study of reference, meaning, or truth. The term can be used to refer to subfields of several distinct disciplines, including philosophy
Philosophy (f ...
.
SassScript provides the following mechanisms:
variable
Variable may refer to:
* Variable (computer science), a symbolic name associated with a value and whose associated value may be changed
* Variable (mathematics), a symbol that represents a quantity in a mathematical expression, as used in many ...
s,
nesting,
mixins, and selector
inheritance
Inheritance is the practice of receiving private property, Title (property), titles, debts, entitlements, Privilege (law), privileges, rights, and Law of obligations, obligations upon the death of an individual. The rules of inheritance differ ...
.
History
Sass was initially designed by
Hampton Catlin
Hampton Lintorn-Catlin ( né Catlin; born 1982) is an American computer programmer, programming language inventor, gay rights advocate, and author, best known as the creator of the Sass and Haml markup languages. Hampton was a Vice President of ...
and developed by Natalie Weizenbaum.
After its initial versions, Weizenbaum and Chris Eppstein have continued to extend Sass with SassScript, a scripting language used in Sass files.
Major implementations
SassScript was implemented in multiple languages, the noteworthy implementations are:
* The official open-source
Dart
Dart or DART may refer to:
* Dart, the equipment in the game of darts
Arts, entertainment and media
* Dart (comics), an Image Comics superhero
* Dart, a character from ''G.I. Joe''
* Dart, a ''Thomas & Friends'' railway engine character
* Dar ...
implementation.
* The official "sass"
node
In general, a node is a localized swelling (a "knot") or a point of intersection (a vertex).
Node may refer to:
In mathematics
*Vertex (graph theory), a vertex in a mathematical graph
*Vertex (geometry), a point where two or more curves, lines, ...
module on
npm, which is Dart Sass compiled to pure JavaScript.
* The official "sass-embedded" node module which is a JavaScript wrapper around the native Dart executable.
* The original
open-source
Open source is source code that is made freely available for possible modification and redistribution. Products include permission to use the source code, design documents, or content of the product. The open-source model is a decentralized sof ...
Ruby
A ruby is a pinkish red to blood-red colored gemstone, a variety of the mineral corundum ( aluminium oxide). Ruby is one of the most popular traditional jewelry gems and is very durable. Other varieties of gem-quality corundum are called sa ...
implementation created in 2006,
since deprecated due to the lack of maintainers and reached End-of-Life in March 2019.
* libSass, the official open-source
C++ implementation, deprecated in October 2020.
*The deprecated "node-sass" node module on
npm, based on the deprecated libSass.
* JSass, an unofficial
Java
Java (; id, Jawa, ; jv, ꦗꦮ; su, ) is one of the Greater Sunda Islands in Indonesia. It is bordered by the Indian Ocean to the south and the Java Sea to the north. With a population of 151.6 million people, Java is the world's List ...
implementation, based on the deprecated libSass.
* phamlp, an unofficial Sass/SCSS implementation in
PHP
PHP is a general-purpose scripting language geared toward web development. It was originally created by Danish-Canadian programmer Rasmus Lerdorf in 1993 and released in 1995. The PHP reference implementation is now produced by The PHP Group ...
.
*
Vaadin Vaadin () is an open-source web application development platform for Java. Vaadin includes a set of Web Components, a Java web framework, and a set of tools that enable developers to implement modern web graphical user interfaces (GUI) using the Jav ...
has a Java implementation of Sass.
*
Firebug, a
Firefox XUL ("legacy")
extension
Extension, extend or extended may refer to:
Mathematics
Logic or set theory
* Axiom of extensionality
* Extensible cardinal
* Extension (model theory)
* Extension (predicate logic), the set of tuples of values that satisfy the predicate
* E ...
for web development.
[Sass (Syntactically Awesome StyleSheets)](_blank)
SASS_REFERENCE 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 (
:
).
SassScript supports four data types:
* Numbers (including units)
*
String
String or strings may refer to:
*String (structure), a long flexible structure made from threads twisted together, which is used to tie, bind, or hang other objects
Arts, entertainment, and media Films
* ''Strings'' (1991 film), a Canadian anim ...
s (with quotes or without)
* Colors (name, or names)
*
Booleans
Variables can be
arguments to or results from one of several available
functions.
[Module: Sass::Script::Functions](_blank)
Sass Functions During translation, the values of the variables are inserted into the output CSS document.
Nesting
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.
Loops
Sass allows for iterating over variables using , and , which can be used to apply different styles to elements with similar classes or ids.
Arguments
Mixins also support
arguments.
In combination
Selector inheritance
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.
libSass
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
Layer0 (previously Moovweb), is an American software company based in San Francisco, California
California is a state in the Western United States, located along the Pacific Coast. With nearly 39.2million residents across a total area of ...
.
Current Sass maintainer, Chris Eppstein, has expressed intent to contribute as well.
According to Catlin, libSass can be "drop
edinto 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."
The design goals of libSass are:
* Performance – Developers have reported 10x speed up increases over the Ruby implementation of Sass.
* 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
In general, a node is a localized swelling (a "knot") or a point of intersection (a vertex).
Node may refer to:
In mathematics
*Vertex (graph theory), a vertex in a mathematical graph
*Vertex (geometry), a point where two or more curves, lines, ...
,
Go, and
Ruby
A ruby is a pinkish red to blood-red colored gemstone, a variety of the mineral corundum ( aluminium oxide). Ruby is one of the most popular traditional jewelry gems and is very durable. Other varieties of gem-quality corundum are called sa ...
.
* Compatibility – libSass's goal is full compatibility with the official Ruby implementation of Sass. This goal has been achieved on libsass 3.3.
IDE integration
See also
*
Less (stylesheet language)
Less (Leaner Style Sheets; sometimes stylized as LESS) is a dynamic preprocessor style sheet language that can be compiled into Cascading Style Sheets (CSS) and run on the client side or server side.
Designed by Alexis Sellier, Less is influence ...
*
Stylus (stylesheet language)
A stylus (plural styli or styluses) is a writing utensil or a small tool for some other form of marking or shaping, for example, in pottery. It can also be a computer accessory that is used to assist in navigating or providing more precision w ...
References
External links
*
{{Stylesheet languages
Free computer libraries
Programming languages created in 2006
Ruby (programming language)
Software using the MIT license
Stylesheet languages