Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Organizing Stylesheets with CSS Pre-processors
Search
Sponsored
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
Erik Frisk
September 05, 2013
Programming
190
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Organizing Stylesheets with CSS Pre-processors
Erik Frisk
September 05, 2013
More Decks by Erik Frisk
See All by Erik Frisk
Seven UX Design Rules
erikfrisk
10
450
The Science of Design
erikfrisk
3
220
Responsive Web Design in a Nutshell
erikfrisk
0
450
Intro to HTML5
erikfrisk
2
170
Graceful Degradation with Modernizr
erikfrisk
1
170
Customer On-boarding in Practice
erikfrisk
2
140
Other Decks in Programming
See All in Programming
C# and C++ Interoperability - cho-dotnetnew
harukasao
0
280
LLMによるContent Moderationの本番運用の裏側と品質担保への挑戦
suikabar
3
710
気づいたらRubyで100作品 ー クリエイティブコーディングが生活の一部になるまで / 100 Ruby Sketches Later: How Creative Coding Became Part of My Life
chobishiba
3
590
メソッドのジェネリクスでGoの夢は広がるか? / Kyoto.go #65
utgwkk
3
850
AIで効率化できた業務・日常
ochtum
0
140
セキュリティの専門家じゃなくてもできる。「セキュリティ意識」をアップデートして サプライチェーン攻撃への耐性を高めよう。
tk3fftk
5
890
Developing with AI Agents — Codex, Claude Code & Cowork Practical Guide
x5gtrn
PRO
0
1.3k
Mujeres en SEO Summit 2026 - Greatest Disaster Hits en Web Performance
guaca
0
190
IBM Bobを活用したレガシーアプリの最新化
oniak3ibm
PRO
1
200
生成AI時代にこそ効くGo | Why Go Works in the Age of Generative AI
mom0tomo
8
3.3k
ADKを使って簡単にAIエージェントを作ってみよう
k1mu21
0
270
並列実装の現場、2ヶ月間実務でAIを使い倒したAIもPCも私も限界が近い
ming_ayami
0
130
Featured
See All Featured
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
31
2.8k
Paper Plane (Part 1)
katiecoart
PRO
0
9.1k
Groundhog Day: Seeking Process in Gaming for Health
codingconduct
0
210
The agentic SEO stack - context over prompts
schlessera
0
820
New Earth Scene 8
popppiees
3
2.3k
10 Git Anti Patterns You Should be Aware of
lemiorhan
PRO
659
62k
KATA
mclloyd
PRO
35
15k
How GitHub (no longer) Works
holman
316
150k
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
49
3.5k
SEOcharity - Dark patterns in SEO and UX: How to avoid them and build a more ethical web
sarafernandez
0
210
What does AI have to do with Human Rights?
axbom
PRO
1
2.2k
[SF Ruby Conf 2025] Rails X
palkan
2
1.1k
Transcript
CSS Pre-processors Harder, Better, Faster, Stronger leanmachine.se ▪
[email protected]
▪
2013-09-06
CSS is dumb!
CSS is dumb! Not DRY (Don’t Repeat Yourself)
CSS is dumb! Not DRY (Don’t Repeat Yourself) Not Maintainable
CSS is dumb! Not DRY (Don’t Repeat Yourself) Not Maintainable
Not Readable
.data-table { width: 700px; margin: 30px auto; background: #f8f8f8; }
.data-table tr { border: 1px solid green; } .data-table tr td { padding: 10px; } .data-table tr td.highlight { background: green; }
.data-table { width: 700px; margin: 30px auto; background: #f8f8f8; }
.data-table tr { border: 1px solid green; } .data-table tr td { padding: 10px; } .data-table tr td.highlight { background: green; } .data-table { width: 700px; margin: 30px auto; background: #f8f8f8; tr { border: 1px solid green; td { padding: 10px; &.highlight { background: green; } } } }
BETTER CSS SYNTAX NORMAL CSS COMPILER BROWSER
LESS lesscss.org .data-table { width: 700px; margin: 30px auto; background:
#f8f8f8; tr { border: 1px solid green; td { padding: 10px; &.highlight { background: green; } } } } Sass sass-lang.com .data-table { width: 700px; margin: 30px auto; background: #f8f8f8; tr { border: 1px solid green; td { padding: 10px; &.highlight { background: green; } } } } Stylus learnboost.github.io/stylus .data-table width 700px margin 30px auto background #f8f8f8 tr border 1px solid green td padding 10px &.highlight background green
Nice Features: Nesting Variables Mixins Operations
.data-table { width: 700px; margin: 30px auto; background: #f8f8f8; tr
{ border: 1px solid green; td { padding: 10px; &.highlight { background: green; } } } } Nesting .data-table { width: 700px; margin: 30px auto; background: #f8f8f8; } .data-table tr { border: 1px solid #E82C64; } .data-table tr td { padding: 10px; } .data-table tr td.highlight { background: #E82C64; }
.data-table { width: 700px; margin: 30px auto; background: #f8f8f8; }
.data-table tr { border: 1px solid #E82C64; } .data-table tr td { padding: 10px; } .data-table tr td.highlight { background: #E82C64; } @pink: #E82C64; @pageWidth: 700px; .data-table { width: @pageWidth; margin: 30px auto; background: #f8f8f8; tr { border: 1px solid @pink; td { padding: 10px; &.highlight { background: @pink; } } } } Variables
.data-table { width: 700px; margin: 30px auto; background: #f8f8f8; }
.data-table tr { border: 1px solid #E82C64; } .data-table tr td { padding: 10px; } .data-table tr td.highlight { background: #E82C64; } @pink: #E82C64; @pageWidth: 700px; .reusable-table() { width: @pageWidth; margin: 30px auto; background: #f8f8f8; tr { border: 1px solid black; td { padding: 10px; &.highlight { background: @pink; } } } } .data-table { .reusable-table(); tr { border: 1px solid @pink; } } Mixins
.data-table { width: 700px; margin: 30px auto; background: #f8f8f8; }
.data-table tr { border: 1px solid #E82C64; } .data-table tr td { padding: 10px; } .data-table tr td.highlight { background: #E82C64; } @pink: #E82C64; @pageWidth: 700px; .reusable-table() { width: @pageWidth; margin: 30px auto; background: #f8f8f8; tr { border: 1px solid black; td { padding: 10px; &.highlight { background: @pink; } } } } .data-table { .reusable-table(); tr { border: 1px solid @pink; } } Mixins ???
@pink: #E82C64; @pageWidth: 700px; .reusable-table() { width: @pageWidth; margin: 30px
auto; background: #f8f8f8; tr { border: 1px solid black; td { padding: 10px; &.highlight { background: @pink; } } } } .data-table { .reusable-table(); tr { border: 1px solid @pink; } } Mixins
@pink: #E82C64; @pageWidth: 700px; .reusable-table(@w:700px) { width: @w; margin: 30px
auto; background: #f8f8f8; tr { border: 1px solid black; td { padding: 10px; &.highlight { background: @pink; } } } } .data-table { .reusable-table(); tr { border: 1px solid @pink; } } Mixins
@pink: #E82C64; @pageWidth: 700px; @lightPink: lighten(@pink, 20%); .data-table { .reusable-table();
tr { border: 1px solid @lightPink; } } Operations
@pink: #E82C64; @pageWidth: 700px; @lightPink: lighten(@pink, 20%); @cellWidth: 200px; @cellPadding:
20px; .data-table { .reusable-table(); tr { border: 1px solid @lightPink; td { width: (@cellWidth - 2*@cellPadding); padding: @cellPadding; } } } Operations
A “Design Pattern” for HTML/CSS using pre-processors
HTML Content + Style
HTML Content CSS Style
HTML Content CSS Style • Can’t create a separate “style
structure”
HTML Content CSS Style • Can’t create a separate “style
structure” • Too many classes pollute HTML with style info
HTML Content CSS Style ?
HTML Content LESS structure.less Mirror HTML structure and tie in
styles LESS mixins.less Styles
HTML Content LESS structure.less Mirror HTML structure and tie in
styles LESS mixins.less Styles LESS reset.less Resets, defaults, variables
Workflow
Server Web server that compiles automatically JS that compiles on
page load App or command line tool
Logo Page 1 Page 2 Page 3 The best thing
since sliced bread in three easy steps. Step 1 Step 2 Step 3 Heading Cupcake ipsum dolor sit amet pie dessert faworki fruitcake. Bear claw cupcake candy. Powder ice cream muffin sweet. Cupcake sugar plum bear claw chupa chups wafer biscuit chocolate cake chocolate bar. Cotton candy sweet roll carrot cake oat cake gingerbread toffee jelly-o chocolate chocolate cake. Tart chocolate lemon drops jelly-o muffin oat cake. Pudding candy canes wypas candy carrot cake. Pastry wypas tiramisu chocolate. Pudding pastry brownie cupcake soufflé. Macaroon muffin danish dessert jujubes
Logo Page 1 Page 2 Page 3 The best thing
since sliced bread in three easy steps. Step 1 Step 2 Step 3 Heading Cupcake ipsum dolor sit amet pie dessert faworki fruitcake. Bear claw cupcake candy. Powder ice cream muffin sweet. Cupcake sugar plum bear claw chupa chups wafer biscuit chocolate cake chocolate bar. Cotton candy sweet roll carrot cake oat cake gingerbread toffee jelly-o chocolate chocolate cake. Tart chocolate lemon drops jelly-o muffin oat cake. Pudding candy canes wypas candy carrot cake. Pastry wypas tiramisu chocolate. Pudding pastry brownie cupcake soufflé. Macaroon muffin danish dessert jujubes Exercise Build out this simple page using LESS and the suggested stylesheet design pattern (structure.less, mixins.less, reset.less).
leanmachine.se ▪
[email protected]
▪ 2013-09-06