SlideShare a Scribd company logo
1 of 13
SASS VS SCSS
Peggy
2015/05/08
CSS
缺點
• Repetition causes maintenance
challenges
• Relationships are not clear
• Reasons are trapped in the mind of the
designer
.msg {
padding: 24px;
}
.msg h3 {
padding: 24px;
margin: -24px -24px 0;
}
SASS
• Since the creation of Sass nearly 5 years ago, it has been plagued by many levels of
controversy.
• It billed itself as "a better CSS" and added brand new features unheard of to CSS
authors such as variables, nesting, mixins and inheritance.
• Sass also introduced an entirely different indentation-oriented syntax and a brand new
perspective on how to author CSS.
(September 12, 2011 ~ Editorial, John W. Long)
Using CSS2SASS
CSS
header .nav {
margin-top: 100px;
}
header .nav li {
margin-left: 10px;
}
header .nav li a {
height: 30px;
line-height: 10px;
}
SASS
header .nav
margin-top: 100px
li
margin-left: 10px
a
height: 30px
line-height: 10px
The Same Style Rules
CSS
.footer {
color: #b3b3b3;
background-color: #fafafa;
}
.copy {
color: #b3b3b3;
background-color: #fafafa;
}
SASS
.footer, .copy
color: #b3b3b3
background-color: #fafafa
Pseudo-class And Selector Combination
CSS
.button:hover {
color: #ffffff;
background-color: #bf813d;
}
.button.active {
background-color: #986731;
}
SASS
.button
&:hover
color: #ffffff
background-color: #bf813d
&.active
background-color: #986731
Pros For Sass
• Reason #1: The Sass syntax is more concise
• Reason #2: The Sass syntax is easier to read
• Because of its rules about indentation, it's kind of hard to write unreadable
Sass. Sass forces you to write your code the same way every time.
• Reason #3: The Sass syntax doesn't complain about missing semi-colons
SCSS
• In version 3 of Sass, the SCSS (Sassy CSS) syntax was introduced as "the new main
syntax" for Sass and builds on the existing syntax of CSS.
• It uses brackets(括弧) and semi-colons(分號) just like CSS. It doesn't care about
indentation levels or white-space.
• In fact, Sass's SCSS syntax is a superset of CSS – which means SCSS contains all the features
of CSS, but has been expanded to include the features of Sass as well. In layman's terms,
any valid CSS is valid SCSS.
• And in the end, SCSS has the exact same features as the Sass syntax, minus the opinionated
syntax.
NESTING 巢狀寫法
CSS
#navbar { width: 80%; height: 23px; }
#navbar ul { list-style-type: none; }
#navbar li { float: left; }
#navbar li a { font-weight: bold; }
SCSS
#navbar {
width: 80%;
height: 23px;
ul { list-style-type: none; }
li {
float: left;
a { font-weight: bold; }
}
}
PARENT REFERENCES 父層參照
CSS
a { color: #ce4dd6; }
a:hover { color: #ffb3ff; }
a:visited { color: #c458cb; }
SCSS
a {
color: #ce4dd6;
&:hover { color: #ffb3ff; }
&:visited { color: #c458cb; }
}
VARIABLES 變數
CSS
#navbar {
color: #ce4dd6;
border-bottom: #ce4dd6 2px
solid;
}
SCSS
$main-color: #ce4dd6;
#navbar {
color: $main-color;
border-bottom: $main-color
2px solid;
}
MIXINS
CSS
nav a {
text-decoration: none;
}
nav a:hover {
text-decoration: underline;
}
SCSS
@mixin hover-link {
text-decoration: none;
&:hover { text-decoration:
underline; }
}
nav a { @include hover-link; }
PROS FOR SCSS
• Reason #1: SCSS is more expressive
• Reason #2: SCSS encourages proper nesting of rules
• Reason #3: SCSS encourages more modular code with @extend
• Reason #4: SCSS allows me to write better inline documentation
• Reason #5: Existing CSS tools often work with SCSS
• Reason #6: Integration with an existing CSS codebase is much easier
• Reason #7: SCSS provides a much lower barrier to entry
• Reason #8: SCSS could become the next version of CSS

More Related Content

Similar to SASS VS SCSS - The Ultimate Guide

SCSS Implementation
SCSS ImplementationSCSS Implementation
SCSS ImplementationAmey Parab
 
CSS 開發加速指南-Sass & Compass
CSS 開發加速指南-Sass & CompassCSS 開發加速指南-Sass & Compass
CSS 開發加速指南-Sass & CompassLucien Lee
 
Css preprocessor-140606115334-phpapp01
Css preprocessor-140606115334-phpapp01Css preprocessor-140606115334-phpapp01
Css preprocessor-140606115334-phpapp01Anam Hossain
 
CSS preprocessor: why and how
CSS preprocessor: why and howCSS preprocessor: why and how
CSS preprocessor: why and howmirahman
 
Syntactically awesome stylesheets (Sass)
Syntactically awesome stylesheets (Sass)Syntactically awesome stylesheets (Sass)
Syntactically awesome stylesheets (Sass)Tahmina Khatoon
 
Authoring Stylesheets with Compass & Sass
Authoring Stylesheets with Compass & SassAuthoring Stylesheets with Compass & Sass
Authoring Stylesheets with Compass & Sasschriseppstein
 
SASS, Compass, Gulp, Greensock
SASS, Compass, Gulp, GreensockSASS, Compass, Gulp, Greensock
SASS, Compass, Gulp, GreensockMarco Pinheiro
 
Sass:-Syntactically Awesome Stylesheet by Shafeeq
Sass:-Syntactically Awesome Stylesheet by ShafeeqSass:-Syntactically Awesome Stylesheet by Shafeeq
Sass:-Syntactically Awesome Stylesheet by ShafeeqDignitasDigital1
 
An Introduction to CSS Preprocessors (SASS & LESS)
An Introduction to CSS Preprocessors (SASS & LESS)An Introduction to CSS Preprocessors (SASS & LESS)
An Introduction to CSS Preprocessors (SASS & LESS)Folio3 Software
 
Sass and Compass - Getting Started
Sass and Compass - Getting StartedSass and Compass - Getting Started
Sass and Compass - Getting Startededgincvg
 

Similar to SASS VS SCSS - The Ultimate Guide (20)

SASS Lecture
SASS Lecture SASS Lecture
SASS Lecture
 
Introduction to sass
Introduction to sassIntroduction to sass
Introduction to sass
 
SASS Preprocessor
SASS PreprocessorSASS Preprocessor
SASS Preprocessor
 
SCSS Implementation
SCSS ImplementationSCSS Implementation
SCSS Implementation
 
CSS 開發加速指南-Sass & Compass
CSS 開發加速指南-Sass & CompassCSS 開發加速指南-Sass & Compass
CSS 開發加速指南-Sass & Compass
 
Sass_Cubet seminar
Sass_Cubet seminarSass_Cubet seminar
Sass_Cubet seminar
 
Css preprocessor-140606115334-phpapp01
Css preprocessor-140606115334-phpapp01Css preprocessor-140606115334-phpapp01
Css preprocessor-140606115334-phpapp01
 
CSS preprocessor: why and how
CSS preprocessor: why and howCSS preprocessor: why and how
CSS preprocessor: why and how
 
Syntactically awesome stylesheets (Sass)
Syntactically awesome stylesheets (Sass)Syntactically awesome stylesheets (Sass)
Syntactically awesome stylesheets (Sass)
 
Advanced sass
Advanced sassAdvanced sass
Advanced sass
 
Authoring Stylesheets with Compass & Sass
Authoring Stylesheets with Compass & SassAuthoring Stylesheets with Compass & Sass
Authoring Stylesheets with Compass & Sass
 
CSS3
CSS3CSS3
CSS3
 
SASS, Compass, Gulp, Greensock
SASS, Compass, Gulp, GreensockSASS, Compass, Gulp, Greensock
SASS, Compass, Gulp, Greensock
 
UNIT 3.ppt
UNIT 3.pptUNIT 3.ppt
UNIT 3.ppt
 
Sass compass
Sass compassSass compass
Sass compass
 
PostCss
PostCssPostCss
PostCss
 
Sass:-Syntactically Awesome Stylesheet by Shafeeq
Sass:-Syntactically Awesome Stylesheet by ShafeeqSass:-Syntactically Awesome Stylesheet by Shafeeq
Sass:-Syntactically Awesome Stylesheet by Shafeeq
 
Less
LessLess
Less
 
An Introduction to CSS Preprocessors (SASS & LESS)
An Introduction to CSS Preprocessors (SASS & LESS)An Introduction to CSS Preprocessors (SASS & LESS)
An Introduction to CSS Preprocessors (SASS & LESS)
 
Sass and Compass - Getting Started
Sass and Compass - Getting StartedSass and Compass - Getting Started
Sass and Compass - Getting Started
 

More from LearningTech

More from LearningTech (20)

vim
vimvim
vim
 
ReactJs
ReactJsReactJs
ReactJs
 
Docker
DockerDocker
Docker
 
Semantic ui
Semantic uiSemantic ui
Semantic ui
 
node.js errors
node.js errorsnode.js errors
node.js errors
 
Process control nodejs
Process control nodejsProcess control nodejs
Process control nodejs
 
Expression tree
Expression treeExpression tree
Expression tree
 
SQL 效能調校
SQL 效能調校SQL 效能調校
SQL 效能調校
 
flexbox report
flexbox reportflexbox report
flexbox report
 
Vic weekly learning_20160504
Vic weekly learning_20160504Vic weekly learning_20160504
Vic weekly learning_20160504
 
Reflection & activator
Reflection & activatorReflection & activator
Reflection & activator
 
Peggy markdown
Peggy markdownPeggy markdown
Peggy markdown
 
Node child process
Node child processNode child process
Node child process
 
20160415ken.lee
20160415ken.lee20160415ken.lee
20160415ken.lee
 
Peggy elasticsearch應用
Peggy elasticsearch應用Peggy elasticsearch應用
Peggy elasticsearch應用
 
Expression tree
Expression treeExpression tree
Expression tree
 
Vic weekly learning_20160325
Vic weekly learning_20160325Vic weekly learning_20160325
Vic weekly learning_20160325
 
D3js learning tips
D3js learning tipsD3js learning tips
D3js learning tips
 
git command
git commandgit command
git command
 
Asp.net MVC DI
Asp.net MVC DIAsp.net MVC DI
Asp.net MVC DI
 

Recently uploaded

08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptxLBM Solutions
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?XfilesPro
 
Azure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAzure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAndikSusilo4
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhisoniya singh
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 

Recently uploaded (20)

08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptx
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?
 
Azure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAzure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & Application
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 

SASS VS SCSS - The Ultimate Guide

  • 2. CSS 缺點 • Repetition causes maintenance challenges • Relationships are not clear • Reasons are trapped in the mind of the designer .msg { padding: 24px; } .msg h3 { padding: 24px; margin: -24px -24px 0; }
  • 3. SASS • Since the creation of Sass nearly 5 years ago, it has been plagued by many levels of controversy. • It billed itself as "a better CSS" and added brand new features unheard of to CSS authors such as variables, nesting, mixins and inheritance. • Sass also introduced an entirely different indentation-oriented syntax and a brand new perspective on how to author CSS. (September 12, 2011 ~ Editorial, John W. Long)
  • 4. Using CSS2SASS CSS header .nav { margin-top: 100px; } header .nav li { margin-left: 10px; } header .nav li a { height: 30px; line-height: 10px; } SASS header .nav margin-top: 100px li margin-left: 10px a height: 30px line-height: 10px
  • 5. The Same Style Rules CSS .footer { color: #b3b3b3; background-color: #fafafa; } .copy { color: #b3b3b3; background-color: #fafafa; } SASS .footer, .copy color: #b3b3b3 background-color: #fafafa
  • 6. Pseudo-class And Selector Combination CSS .button:hover { color: #ffffff; background-color: #bf813d; } .button.active { background-color: #986731; } SASS .button &:hover color: #ffffff background-color: #bf813d &.active background-color: #986731
  • 7. Pros For Sass • Reason #1: The Sass syntax is more concise • Reason #2: The Sass syntax is easier to read • Because of its rules about indentation, it's kind of hard to write unreadable Sass. Sass forces you to write your code the same way every time. • Reason #3: The Sass syntax doesn't complain about missing semi-colons
  • 8. SCSS • In version 3 of Sass, the SCSS (Sassy CSS) syntax was introduced as "the new main syntax" for Sass and builds on the existing syntax of CSS. • It uses brackets(括弧) and semi-colons(分號) just like CSS. It doesn't care about indentation levels or white-space. • In fact, Sass's SCSS syntax is a superset of CSS – which means SCSS contains all the features of CSS, but has been expanded to include the features of Sass as well. In layman's terms, any valid CSS is valid SCSS. • And in the end, SCSS has the exact same features as the Sass syntax, minus the opinionated syntax.
  • 9. NESTING 巢狀寫法 CSS #navbar { width: 80%; height: 23px; } #navbar ul { list-style-type: none; } #navbar li { float: left; } #navbar li a { font-weight: bold; } SCSS #navbar { width: 80%; height: 23px; ul { list-style-type: none; } li { float: left; a { font-weight: bold; } } }
  • 10. PARENT REFERENCES 父層參照 CSS a { color: #ce4dd6; } a:hover { color: #ffb3ff; } a:visited { color: #c458cb; } SCSS a { color: #ce4dd6; &:hover { color: #ffb3ff; } &:visited { color: #c458cb; } }
  • 11. VARIABLES 變數 CSS #navbar { color: #ce4dd6; border-bottom: #ce4dd6 2px solid; } SCSS $main-color: #ce4dd6; #navbar { color: $main-color; border-bottom: $main-color 2px solid; }
  • 12. MIXINS CSS nav a { text-decoration: none; } nav a:hover { text-decoration: underline; } SCSS @mixin hover-link { text-decoration: none; &:hover { text-decoration: underline; } } nav a { @include hover-link; }
  • 13. PROS FOR SCSS • Reason #1: SCSS is more expressive • Reason #2: SCSS encourages proper nesting of rules • Reason #3: SCSS encourages more modular code with @extend • Reason #4: SCSS allows me to write better inline documentation • Reason #5: Existing CSS tools often work with SCSS • Reason #6: Integration with an existing CSS codebase is much easier • Reason #7: SCSS provides a much lower barrier to entry • Reason #8: SCSS could become the next version of CSS

Editor's Notes

  1. 更簡潔
  2. 理由1:SCSS是更具表现力 理由2:SCSS鼓励规则正确的嵌套 理由3:SCSS鼓励更多的模块化代码@extend 理由4:SCSS让我写更好的内联文档 理由5:现有的CSS工具往往与SCSS工作 理由6:与现有的代码库的CSS集成更容易 理由7:SCSS提供了一个非常低的门槛 理由#8:SCSS可能成为CSS的下一版本