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
Breaking Good Habits
Search
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
Harry Roberts
February 12, 2012
Design
5.7k
22
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Breaking Good Habits
Talk first given at The Digital Barn (Barnsley, UK) 11 February, 2012.
Harry Roberts
February 12, 2012
More Decks by Harry Roberts
See All by Harry Roberts
Build for the Web, Build on the Web, Build With the Web
csswizardry
0
460
Site-Speed That Sticks
csswizardry
13
1.2k
How to Think Like a Performance Engineer
csswizardry
28
2.7k
cache rules everything
csswizardry
5
3.8k
My Website Is Slow! Where Do I Start?
csswizardry
5
590
Optimising Largest Contentful Paint
csswizardry
37
3.7k
Get Your Head Straight
csswizardry
15
21k
From Milliseconds to Millions: A Look at the Numbers Powering Web Performance
csswizardry
1
2.7k
More Than You Ever Wanted to Know About Resource Hints
csswizardry
6
10k
Other Decks in Design
See All in Design
研修担当者が一番伸びた 熊本市役所✕AI『泥臭いAI研修』のワークショップ設計について
garyuten
2
420
30分でわかるインサイトマネジメント(2025年12月バージョン)
centou
1
680
速く作れるかではなく、速く学べるか ― 学習ループを回すパイロットの途中報告
nagata03
0
520
空間アプリ開発のフィードバックをCodexにするための抽象的なデザインツールの模索
karad
0
150
デザイナーが主導権を握る、AI協業の本音と実践
satosio
7
3.4k
Decksh keywords
ajstarks
0
100
タイル紹介サイト「タイルだもんで」
calpin
0
150
Debiasing Your Software Design Decision-Making @ Flowcon '26
baasie
1
120
怖くないアクセシビリティ -カウンターカルチャーとしてのアッカン東京-
securecat
1
210
Basket_of_love.pdf
terencebasart
0
110
言幹と言葉(Stems & Leaves)
kakukoki
0
110
CULTURE DECK/Frontend Engineer
mhand01
0
1.4k
Featured
See All Featured
Bridging the Design Gap: How Collaborative Modelling removes blockers to flow between stakeholders and teams @FastFlow conf
baasie
0
600
SEO in 2025: How to Prepare for the Future of Search
ipullrank
3
3.6k
The Myth of the Modular Monolith - Day 2 Keynote - Rails World 2024
eileencodes
28
3.5k
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
123
22k
Ruling the World: When Life Gets Gamed
codingconduct
0
270
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
12
1.2k
Bash Introduction
62gerente
615
220k
Music & Morning Musume
bryan
47
7.3k
A Guide to Academic Writing Using Generative AI - A Workshop
ks91
PRO
1
340
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
230
23k
Navigating Team Friction
lara
192
16k
From Legacy to Launchpad: Building Startup-Ready Communities
dugsong
0
240
Transcript
None
Breaking Good Habits Harry Roberts—@csswizardry
Harry who?! •Web designer/developer •Senior UI Developer—BSkyB •@csswizardry •csswizardry.com
Necessary explanation of the cheesy, overly- cryptic talk title.
Web standards… •A great idea? Definitely! •Well intentioned? You bet!
•Ambiguous? Sadly :( •Open to interpretation? Unfortunately…
…web standards •Rules? Definitely not!
Best practices •Best for who? •What are we achieving? •What
do we really want to achieve? •Are we always solving the right problems for the right people?
Good habits? •Avoiding classes and IDs •‘Handcrafting’ our CSS •Avoiding
extra markup
Bad habits? •Classitis—using too many classes •Grid systems •Extra markup
•‘Insemantic’ class names
We’ve been solving the wrong problems for the wrong people!
None
The 4 ‘-ility’s •Maintainability •Flexibility •Extensibility •Predictability
Maintainability
Flexibility
body > div:nth-of-type(2) > article:first- child > p:first-child{ font-size:1.2em }
<p>Lorem ipsum dolor sit amet...</p>
Be ?#*@ing explicit!
.intro{ font-size:1.2em; } <p class=intro>Lorem ipsum dolor sit amet...</p>
Specific !== explicit
Extensibility
Extensible •Stop thinking in pages… •…think in components… •…then think
in abstractions.
Predictability
Expect the unexpected Always build like your client’s CMS is
a bulldozer…
None
CSS selectors
IDs •Don’t use IDs in CSS •Ever.
IDs •No advantage over classes. •Waaaaaay overly specific. •Not dissimilar
to !important •Everything you can do with an ID can be done with a class.
Classes •No one uses classes except browsers and other developers
(and microformats). •Classes are neither semantic or insemantic; they’re sensible or insensible.
None
.red .red{ color:red; } <h1>I am a <span class=red>designer</span> and
<span class=red>developer</span></h1>
.red .red{ color:blue; /* WTF */ } <h1>I am a
<span class=red>designer</span> and <span class=red>developer</span></h1>
.brand .brand{ color:#BADA55; /* FTW */ } <h1>I am a
<span class=brand>designer</span> and <span class=brand>developer</span></h1>
None
Objects and abstractions
The media object bit.ly/cCY3Ew
The media object bit.ly/cCY3Ew
The media object bit.ly/cCY3Ew
The media object bit.ly/cCY3Ew
The media object bit.ly/cCY3Ew <div class=media> <img class=img> <p class=body>Lorem
ipsum...</p> </div> .media,.body { overflow:hidden; } .img { float:left; margin-right:20px; } .img img { display:block; }
The media object bit.ly/cCY3Ew <div class=media> <img class=img> <div class=body>
<p>Lorem ipsum...</p> <a href>Read more...</a> </div> </div>
None
Nicole Sullivan @stubbornella
The nav abstraction bit.ly/oD2M9n
.nav{ list-style:none; margin-left:0; } .nav li{ display:inline; } .nav a{
display:inline-block; } The nav abstraction bit.ly/oD2M9n
<ol class="nav breadcrumb">...</ol> .breadcrumb li:before{ content:"» "; } .breadcrumb li:first-child:before{
content:""; } Breadcrumbs…? bit.ly/oD2M9n
The island object bit.ly/oqQ7JJ
The island object bit.ly/oqQ7JJ <div class=island>...</div> .island{ padding:1.5em; } .island
> :last-child{ margin-bottom:0; }
The island object bit.ly/oqQ7JJ <div class="island promo">...</div> .island.promo{ color:#fff; background-color:#C0FFEE;
}
Double stranded heading hierarchy h1,.alpha { font-size:; line-height:; } h2,.beta
{ font-size:; line-height:; } h3,.gamma { font-size:; line-height:; } h4,.delta { font-size:; line-height:; } h5,.epsilon { font-size:; line-height:; } h6,.zeta { font-size:; line-height:; }
Double stranded heading hierarchy <div class=twitter> <h3 class=delta>Recent tweets</h3> ...
</div>
None
Grid systems
None
Abstract layout into its own layer Keep components free of
dimensions
csswizardry.com/fluid-grids
Straighten up! @media(max-width:480px){ .grid{ float:none; clear:both; width:auto; margin:0; } }
None
All together now!
None
None
None
None
None
None
None
None
None
None
Benefits and side- effects •Sites are faster to build… •…more
robust •…more maintainable •…more consistent •…and incidentally more efficient.
Efficiency on the client side •Reused classes are ‘performance freebies’
•Abstractions mean DRYer code; less to download and evaluate •Classes match quicker than descendants
Now what? •Solve problems for the right people. •Keep yourselves
happy and sane. •Learn when enough is enough; cut yourself some slack.
However bad you think it is, there’s always worse…
Breaking Good Habits •Harry Roberts – @csswizardry •csswizardry.com •Nicole Sullivan
– @stubbornella