Sass (style sheet language)

Sass
Designed byHampton Catlin
DeveloperNatalie Weizenbaum, Chris Eppstein
First appearedNovember 28, 2006; 17 years ago (2006-11-28)
Stable release
1.75.0[1] / April 11, 2024; 7 months ago (2024-04-11)[1]
Typing disciplineDynamic
OSCross-platform
LicenseMIT License
Filename extensions.sass, .scss
Websitesass-lang.com
Major implementations
Dart
Influenced by
CSS (both "indented" and SCSS)

YAML and Haml (indented syntax)

Less (SCSS)
Influenced
Less, Stylus, Tritium, Bootstrap (v4+)

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][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 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,[3] and selector inheritance.[2]

History

Sass was initially designed by Hampton Catlin and developed by Natalie Weizenbaum.[6][7]

Major implementations

SassScript was implemented in multiple languages, the noteworthy implementations are:

  • The official open-source Dart implementation.[8]
  • 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-source Ruby 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]
  • Vaadin has a Java implementation of Sass.[17]
  • Firebug, a Firefox XUL ("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]

SassScript supports four data types:[18]

  • Numbers (including units)
  • Strings (with quotes or without)
  • Colors (name, or names)
  • Booleans

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]

SCSS Sass Compiled CSS
$primary-color: #3bbfce;
$margin: 16px;

.content-navigation {
  border-color: $primary-color;
  color: darken($primary-color, 10%);
}

.border {
  padding: $margin / 2;
  margin: $margin / 2;
  border-color: $primary-color;
}
$primary-color: #3bbfce
$margin: 16px

.content-navigation
  border-color: $primary-color
  color: darken($primary-color, 10%)

.border
  padding: $margin/2
  margin:  $margin/2
  border-color: $primary-color
:root{
    --primary-color:#3bbfce;
    --secondary-color:#2b9eab;
    --margin:8px;
}


.content-navigation {
  border-color: var(--secondary-color)
  color: var(--secondary-color);
}

.border {
  padding: 8px;
  margin: var(--margin);
  border-color: #3bbfce;
}

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.[2]

SCSS Sass Compiled CSS
table.hl {
  margin: 2em 0;
  td.ln {
    text-align: right;
  }
}

li {
  font: {
    family: serif;
    weight: bold;
    size: 1.3em;
  }
}
table.hl 
  margin: 2em 0
  td.ln 
    text-align: right
  
li 
  font: 
    family: serif
    weight: bold
    size: 1.3em
table.hl {
  margin: 2em 0;
}
table.hl td.ln {
  text-align: right;
}

li {
  font-family: serif;
  font-weight: bold;
  font-size: 1.3em;
}

More complicated types of nesting including namespace nesting and parent references are discussed in the Sass documentation.[18]

SCSS Sass Compiled CSS
@mixin table-base {
  th {
    text-align: center;
    font-weight: bold;
  }
  td, th {
    padding: 2px;
  }
}

#data {
  @include table-base;
}
=table-base
  th
    text-align: center
    font-weight: bold
  td, th
    padding: 2px

#data
  +table-base
#data th {
  text-align: center;
  font-weight: bold;
}
#data td, #data th {
  padding: 2px;
}

Loops

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.

Sass Compiled CSS
$squareCount: 4
@for $i from 1 to $squareCount 
  #square-#{$i} 
   background-color: red
   width: 50px * $i
   height: 120px / $i
#square-1 {
  background-color: red;
  width: 50px;
  height: 120px;
}

#square-2 {
  background-color: red;
  width: 100px;
  height: 60px;
}

#square-3 {
  background-color: red;
  width: 150px;
  height: 40px;
}

Arguments

Mixins also support arguments.[2]

Sass Compiled CSS
=left($dist) 
  float: left
  margin-left: $dist

#data 
  +left(10px)
#data {
  float: left;
  margin-left: 10px;
}

In combination

Sass Compiled CSS
=table-base
  th
    text-align: center
    font-weight: bold
  td, th 
    padding: 2px

=left($dist) 
  float: left
  margin-left: $dist

#data 
  +left(10px)
  +table-base
#data {
  float: left;
  margin-left: 10px;
}
#data th {
  text-align: center;
  font-weight: bold;
}
#data td, #data th {
  padding: 2px;
}

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.[2]

Sass Compiled CSS
.error
  border: 1px #f00
  background: #fdd

.error.intrusion 
  font-size: 1.3em
  font-weight: bold

.badError 
  @extend .error
  border-width: 3px
.error, .badError {
  border: 1px #f00;
  background: #fdd;
}

.error.intrusion,
.badError.intrusion {
  font-size: 1.3em;
  font-weight: bold;
}

.badError {
  border-width: 3px;
}

Sass supports multiple inheritance.[18]

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.[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]

IDE integration

IDE integration of Sass
IDE Software
Adobe Dreamweaver CC 2017
Eclipse
Emacs sass-mode
JetBrains IntelliJ IDEA (Ultimate Edition)
JetBrains PhpStorm
JetBrains RubyMine
JetBrains WebStorm
Microsoft Visual Studio Mindscape
Microsoft Visual Studio SassyStudio
Microsoft WebMatrix
NetBeans
Vim haml.zip
Atom
Visual Studio Code
Sublime
Edit+

See also

References

  1. ^ a b "Dart Sass - latest release". github.com.
  2. ^ a b c d e f Media Mark (3.2.12). "Sass - Syntactically Awesome Stylesheets". Sass-lang.com. Retrieved 2014-02-23.{{cite web}}: CS1 maint: numeric names: authors list (link)
  3. ^ a b Firtman, Maximiliano (2013-03-15). Programming the Mobile Web. O'Reilly Media, Inc. ISBN 978-1-4493-3497-0.
  4. ^ Libby, Alex (2019). Introducing Dart Sass: A Practical Introduction to the Replacement for Sass, Built on Dart. Berkeley, CA: Apress. doi:10.1007/978-1-4842-4372-5. ISBN 978-1-4842-4371-8.
  5. ^ Sass - Syntactically Awesome Stylesheets Archived 2013-10-09 at the Wayback Machine Tutorial
  6. ^ "Sass: Syntactically Awesome Style Sheets". sass-lang.com. Archived from the original on 2013-09-01.
  7. ^ "Natalie Weizenbaum's blog". Archived from the original on 2007-10-11.
  8. ^ a b c "Sass / Scss". Drupal.org. 2009-10-21. Archived from the original on 2016-03-10. Retrieved 2014-02-23.
  9. ^ "sass". www.npmjs.com.
  10. ^ "sass-embedded". www.npmjs.com.
  11. ^ Weizenbaum, Natalie. "Ruby Sass Has Reached End-Of-Life « Sass Blog". sass.logdown.com. Retrieved 2019-04-21.
  12. ^ "Sass: Ruby Sass". sass-lang.com. Retrieved 2019-04-21.
  13. ^ "LibSass is Deprecated". sass-lang.com. 26 October 2020.
  14. ^ "node-sass". www.npmjs.com.
  15. ^ "jsass - A Java implementation of the Sass compiler (and some other goodies). - Google Project Hosting". Retrieved 2014-02-23.
  16. ^ "JSass documentation". jsass.readthedocs.io.
  17. ^ "SassCompiler (Vaadin 7.0.7 API)". Vaadin.com. 2013-06-06. Archived from the original on 2014-04-21. Retrieved 2014-02-23.
  18. ^ a b c d e Sass (Syntactically Awesome StyleSheets) SASS_REFERENCE
  19. ^ Module: Sass::Script::Functions Sass Functions
  20. ^ H. Catlin (2012-10-15). "Hampton's 6 Rules of Mobile Design". HTML5 Developer Conference. Archived from the original on 2021-12-15. Retrieved 2013-07-11.
  21. ^ a b M. Catlin (2012-04-30). "libsass". Moovweb Blog. Archived from the original on 2013-05-08. Retrieved 2013-07-11.
  22. ^ A. Stacoviak & A. Thorp (2013-06-26). "Sass, libsass, Haml and more with Hampton Catlin". Archived from the original on 2013-08-06. Retrieved 2013-07-30.
  23. ^ D. Le Nouaille (2013-06-07). "Sassc and Bourbon". Retrieved 2013-07-11.
  24. ^ "Sass Compatibility". sass-compatibility.github.io. Archived from the original on 2019-12-05. Retrieved 2019-11-29.

Further reading

Read other articles:

Konsepsi artis dari Bumi dengan dua satelit alam. Terdapat banyak sekali klaim keberadaan satelit lain Bumi sebagai salah satu dari banyak satelit alam lainnya selain Bulan yang mengorbit Bumi dalam berbagai waktu yang berbeda. Beberapa kandidat telah diusulkan, tetapi tidak ada yang terkonfirmasikan.[1] Referensi ^ I. Klotz - Mystery Mini Moons: How Many Does Earth Have? (2012) - Discovery News Bacaan tambahan Research paper describing horseshoe orbits. Willy Ley: Watchers of the Ski...

 

 

Stand Up Comedy ShowGenreKomediNegara asalIndonesiaRilis asliJaringanMetroTV Stand Up Comedy Show Metro TV adalah acara hiburan yang menampilkan pelawak tunggal (komika) yang ditayangkan oleh stasiun MetroTV. Acara sejenis, yang ditayangkan dalam bentuk kompetisi, ditayangkan oleh Kompas TV dengan tajuk Stand Up Comedy Indonesia (SUCI). Kedua stasiun televisi tersebut membuat acara dengan tema yang sama tetapi format kompetisi dan nama acaranya berbeda. Stand Up Comedy Show & Battle of C...

 

 

Lakhta CenterЛахта центрLakhta Center pada Februari 2021Nama sebelumnyaGazprom Tower, Okhta CenterRekor tinggiTertinggi di Rusia dan Eropa sejak 2017[I]DidahuluiMenara FederationInformasi umumStatusSelesaiLokasiLakhta, Sankt-Peterburg, Sankt-Peterburg, RusiaNegara RusiaKoordinat59°59′13.7″N 30°10′37.3″E / 59.987139°N 30.177028°E / 59.987139; 30.177028Koordinat: 59°59′13.7″N 30°10′37.3″E / 59.987139°N 30.177028°E...

Islam menurut negara Afrika Aljazair Angola Benin Botswana Burkina Faso Burundi Kamerun Tanjung Verde Republik Afrika Tengah Chad Komoro Republik Demokratik Kongo Republik Kongo Djibouti Mesir Guinea Khatulistiwa Eritrea Eswatini Etiopia Gabon Gambia Ghana Guinea Guinea-Bissau Pantai Gading Kenya Lesotho Liberia Libya Madagaskar Malawi Mali Mauritania Mauritius Maroko Mozambik Namibia Niger Nigeria Rwanda Sao Tome dan Principe Senegal Seychelles Sierra Leone Somalia Somaliland Afrika Selatan ...

 

 

American filmsby year 1890s 1890–1899 1900s 1900 1901 1902 1903 19041905 1906 1907 1908 1909 1910s 1910 1911 1912 1913 19141915 1916 1917 1918 1919 1920s 1920 1921 1922 1923 19241925 1926 1927 1928 1929 1930s 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940s 1940 1941 1942 1943 19441945 1946 1947 1948 1949 1950s 1950 1951 1952 1953 19541955 1956 1957 1958 1959 1960s 1960 1961 1962 1963 19641965 1966 1967 1968 1969 1970s 1970 1971 1972 1973 19741975 1976 1977 1978 1979 1980s 1980 1981...

 

 

Pour les articles homonymes, voir Croisée et Fenêtre. Cet article est une ébauche concernant l’architecture ou l’urbanisme. Vous pouvez partager vos connaissances en l’améliorant (comment ?) selon les recommandations des projets correspondants. En architecture, la croisée du transept, parfois appelée intertransept, est la partie du plan d'une église située à l'intersection du transept et du vaisseau principal de la nef. La croisée des grandes églises de l'architecture r...

1. deild 1994 Competizione 1. deild Sport Calcio Edizione 83ª Organizzatore KSI Date dal 23 maggio 1994al 24 settembre 1994 Luogo  Islanda Partecipanti 10 Risultati Vincitore ÍA(15º titolo) Retrocessioni ÞórStjarnan Statistiche Miglior marcatore Mihajlo Biberčić (14 goal) Cronologia della competizione 1993 1995 Manuale La 1. deild 1994 fu la 83ª edizione della massima serie del campionato di calcio islandese disputata tra il 23 maggio e il 24 settembre 1994 e conclu...

 

 

Class of drug This article is about serotonin reuptake inhibitors. For SSRIs, see selective serotonin reuptake inhibitor. Serotonin A serotonin reuptake inhibitor (SRI) is a type of drug which acts as a reuptake inhibitor of the neurotransmitter serotonin (5-hydroxytryptamine, or 5-HT) by blocking the action of the serotonin transporter (SERT). This in turn leads to increased extracellular concentrations of serotonin and, therefore, an increase in serotonergic neurotransmission. It is a type ...

 

 

See also: 2020 in the environment and environmental sciences Overview of the events of 2020 in climate change List of years in climate change … 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 … Art Archaeology Architecture Literature Music Philosophy Science +... This article documents events, research findings, scientific and technological advances, and human actions to measure, predict, mitigate, and adapt to the effects of global...

  لمعانٍ أخرى، طالع كريستيان هانسن (توضيح). هذه المقالة يتيمة إذ تصل إليها مقالات أخرى قليلة جدًا. فضلًا، ساعد بإضافة وصلة إليها في مقالات متعلقة بها. (مارس 2019) كريستيان هانسن (بالدنماركية: Christian Hansen)‏    معلومات شخصية الميلاد 12 أغسطس 1963 (61 سنة)  أودنسه  مواطنة مم...

 

 

Japanese light novel series Toradora!First light novel volume cover, featuring Taiga Aisakaとらドラ!GenreRomantic comedy[1]Slice of life[2] Light novelWritten byYuyuko TakemiyaIllustrated byYasuPublished byASCII Media WorksEnglish publisherNA: Seven Seas EntertainmentImprintDengeki BunkoDemographicMaleOriginal runMarch 10, 2006 – March 10, 2009Volumes10 (List of volumes) Light novelToradora Spin-off!Written byYuyuko TakemiyaIllustrated byYasuPubl...

 

 

Some of this article's listed sources may not be reliable. Please help improve this article by looking for better, more reliable sources. Unreliable citations may be challenged and removed. (October 2012) (Learn how and when to remove this message) Wayne P. Messmer (born July 19, 1950 in Chicago, IL)[1] is a professional speaker, singer, broadcaster, author and actor. He is a professional member of SAG/AFTRA and the National Speakers Association. He was the long-time public address an...

Skyscraper in Chicago, Illinois U.S. Bank Building(2011)General informationTypeOfficeLocation190 South LaSalle Street, Chicago, IllinoisCoordinates41°52′47″N 87°37′58″W / 41.8798°N 87.6327°W / 41.8798; -87.6327Completed1987HeightRoof573 ft (175 m)Technical detailsFloor count40Design and constructionArchitect(s)Johnson Burgee ArchitectsDeveloperThe John Buck Company U.S. Bank Building, formerly 190 South LaSalle Street, is a 573 feet (175 m) t...

 

 

Yunani Artikel ini adalah bagian dari seri Politik dan KetatanegaraanYunani Undang-Undang Dasar Sejarah Undang-Undang Dasar Hak asasi manusia Eksekutif Kepala negara Presiden (daftar): Katerina Sakellaropoulou Departemen Kepresidenan Pemerintah Perdana Menteri (daftar): Kyriakos Mitsotakis Kabinet: Kyr. Mitsotakis Legislatif Ketua: Konstantinos Tasoulas Presidium Konferensi Presiden Komite Parlemen Daerah pemilihan Pembagian Yudikatif Mahkamah Agung Mahkamah Khusus Mahkamah Perdata dan Pidana...

 

 

2009 United Football League seasonRegular seasonDurationOctober 8, 2009 – November 20, 20092009 UFL Championship GameDateNovember 27, 2009SiteSam Boyd Stadium, Whitney, NevadaChampionLas Vegas LocomotivesRunner-upFlorida Tuskers2010 → The 2009 United Football League season—referred to by the professional American football league as the UFL Premiere Season—was the inaugural season of the United Football League. The regular season featured 4 teams playing 6 games each (twice against eac...

此条目序言章节没有充分总结全文内容要点。 (2019年3月21日)请考虑扩充序言,清晰概述条目所有重點。请在条目的讨论页讨论此问题。 哈萨克斯坦總統哈薩克總統旗現任Қасым-Жомарт Кемелұлы Тоқаев卡瑟姆若马尔特·托卡耶夫自2019年3月20日在任任期7年首任努尔苏丹·纳扎尔巴耶夫设立1990年4月24日(哈薩克蘇維埃社會主義共和國總統) 哈萨克斯坦 哈萨克斯坦政府...

 

 

Angkatan Udara SwissSchweizer LuftwaffeForces aériennes suissesForze aeree svizzereAviatica militara svizraLambang Angkatan Udara SwissDibentuk31 Juli 1914; 109 tahun lalu (1914-07-31)Negara SwissTipe unitAngkatan udaraJumlah personel20.000 personel aktifBagian dariAngkatan Bersenjata SwissSitus webvtg.admin.ch/en/organisation/kdo-op/air-forceTokohKomandan Angkatan UdaraJenderal Divisi Peter MerzWakil Komandan Angkatan UdaraBrigadir Werner EpperInsigniaRoundelPesawat tempurRadar pe...

 

 

حرب إفني جزء من إنهاء استعمار أفريقيا والحرب الباردة معلومات عامة التاريخ 23 أكتوبر 1957 – 30 يونيو 1958(8 شهور، و1 أسبوع) الموقع الصحراء الإسبانية، إفني، المغرب النتيجة انتصار دفاعي إسباني[1] إسبانيا تتنازل عن معظم إفني[2] انتقال إفني إلى السيادة المغربية سنة 1969 معا...

Skewered food in Korean cuisine JeokJijim-nureum-jeok (egg-washed and pan-fried skewers)Place of originKorea  Media: JeokKorean nameHangul적Hanja炙Revised RomanizationjeokMcCune–ReischauerchŏkIPA[tɕʌk̚] Jeok (Korean: 적; Hanja: 炙) is a Korean meat dish served with skewers.[1] Jeok is typically made with a large variety of meats, vegetables and mushrooms and is usually served on special occasions such as birthdays (hwangap) and wedding ...

 

 

Overview of tourism in the Indian state of Uttar Pradesh Ram ki Paidi ghat in Ayodhya, Uttar Pradesh, India Taj Mahal, one of the most famous tourist destinations in Uttar Pradesh and India. The famous depiction of Mount Meru at Jambudweep (mythological), in Uttar Pradesh. Prem mandir from main gate in Vrindavan, Mathura, India Situated in the northern part of India, bordering with the capital of India New Delhi, Uttar Pradesh is one of the most popular and an established tourist destination ...