SlideShare a Scribd company logo
DISPLACING WORST PRACTICES
(and making better CSS for all)
Pam Selle
@pamasaur
thewebivore.com
STORYTIME
No.
Yes.
THE PLAN
• What are the ‘worst practices’?
• Identifying
• Solving
• Practices for prevention
IDENTIFYING WORST
PRACTICES
REDUNDANCY
• Symptom: Declaring styles that are inherent, styles that negate
other ones in the chain.
• Solution: Take your freebies and remove things
that don’t matter.
div { display: block; }
.my-class { display: block; float: left; }
img { display: inline-block; }
span { display: inline; }
.nav { position: absolute; float: left; }
REDUNDANCY
Prescription:
Mozilla Developer Network
REPETITION AND
DISORGANIZATION
• Symptom: See many of the same declarations over and over.
• Symptom: See styles being overridden in web inspector.
• Symptom: Having to reset styles because of previous
declarations.
REPETITION AND
DISORGANIZATION
.blue-title { color: blue; font-size: 16px; font-
family: Arial }
.blue-content { color: blue; font-size: 14px; font-
family: Arial }
.blue-title, .blue-content {color: blue; font-
family: Arial; }
.blue-title { font-size: 16px; }
.blue-content { font-size: 14px; }
%blue-thing {color: blue; font-family: Arial; }
.blue-title { @extend %blue-thing; font-size:
16px; }
.blue-content { @extend %blue-thing; font-size:
14px; }
h2 {
border-bottom: 1px solid #ddd;
padding: 10px 0;
float: left;
}
h2.other-title {
border-bottom:none;
padding:0 0 5px;
float:none;
}
.secondary-title {
border-bottom: 1px solid #ddd;
padding: 10px 0;
float: left;
}
.other-title {
padding:0 0 5px;
}
REPETITION AND
DISORGANIZATION
Prescription:
Refactoring, with a side of
architecture.
DETOUR INTO
PREPROCESSORS
• Favorite benefits of preprocessors:
• Partials (architecture)
• Extendables (in Sass 3.2) %
• Sprite benefits (Compass)
OVERSPECIFICITY
• Wasting your time and the browser’s time
.header .logo .title.name { }
#nav ul li a { }
.content a.title { }
.logo > .title { }
.nav li > a { }
.content .title { }
OVERSPECIFICITY
Prescription:
Understanding how browsers
interpret CSS.
HOW BROWSERS EVALUATE CSS
Resources:
https://developers.google.com/speed/docs/best-practices/rendering
https://developer.mozilla.org/en-US/docs/CSS/Writing_Efficient_CSS
The engine evaluates each rule from right to left, starting
from the rightmost selector (called the "key") and moving
through each selector until it finds a match or discards the
rule. (The "selector" is the document element to which the
rule should apply.)
HOW BROWSERS EVALUATE CSS
Specificity:
1. Ids
2. Classes
3.Tags
4. Universals
From SpeciFISHity by Weyl
INVALID DECLARATIONS
• Symptom: Crossed out in web inspector, because it’s wrong,
not overridden.
• Symptom:A style is written, but not rendering. (because it’s
wrong)
• Solution: ⌫.And read the MDN.
.classy {
background-position: inital initial;
font: Arial;
font: 14px/16px Arial sans-serif;
padding: -10px;
}
NO FALLBACKS
• Know what you support, and debug before you see it in the
browser.
• Most common with colors, so add a simple color
(background-, border-) declaration fallback.
• Includes setting position properly -- a common problem in
some browsers
NO FALLBACKS
Common Suspects:
rgba()
linear-gradient
radial-gradient
box-shadow
position: absolute (forgetting a vertical or horizontal position)
INLINE STYLES
The purpose of styles is to to separate
structure from presentation.
Oh, and it will also give you specificity problems.
DISPLACING WORST
PRACTICES
TRAIN EARLY AND OFTEN
TRAIN EARLY
• “Bootcamp”
• Presentations on full stack/tools
• Identify available resources
• Documentation, videos, useful tutorials
• Mentoring
ONBOARDING
• Documentation, Documentation, Documentation
• Onboarding session
• Make past presentations available
KEEP IT UP
• Lightning talks
• Hack Days
• See “Zombies in My Workplace” for more ideas
• http://www.slideshare.net/sbastn/zombies-in-my-workplace
STYLEGUIDES
TEXTUAL STYLEGUIDES
• Document!
• Style
• Idioms
• Structure
Displacing Worst Practices in CSS
TEXTUAL STYLEGUIDES
• Public Styleguides
• Google: http://google-styleguide.googlecode.com/svn/trunk/htmlcssguide.xml
• GitHub: https://github.com/styleguide/css
• ThinkUp: https://github.com/ginatrapani/ThinkUp/wiki/Code-Style-Guide:-CSS
• Manifestos
• Idiomatic CSS: https://github.com/necolas/idiomatic-css
• SMACSS: http://smacss.com/
VISUAL STYLEGUIDES
• Visual Dictionary
• Explain visuals and usage
• Interface with visual designers
Displacing Worst Practices in CSS
KSS
•Generated CSS documentation
http://warpspire.com/kss/
•Learn to generate your own styleguide:
http://warpspire.com/kss/styleguides/
INTERACTIVE STYLEGUIDES
• Put your elements in full context
• Maintain a site-wide brand
• Reduce, Reuse, & Recycle
Displacing Worst Practices in CSS
Displacing Worst Practices in CSS
CODE REVIEW
INTRODUCING CODE REVIEW
• Use your styleguide/documentation as guideline
• Continues mentoring process
• Saves QA time by reviewing before staging
MODULAR ORGANIZATION
INTRODUCING
ARCHITECTURE
• Consider pre-processors
• Consider your build process
• Consider adopting a methodology (OOCSS, etc.)
• Measure everything
• Interface with visual design strategy
FINAL INVENTORY
•Identify and repair misguided styles
•Tools to improve and embark on the joyous path
of maintainability
Thanks.
Pam Selle
thewebivore.com
@pamasaur

More Related Content

PPTX
MidwestJS Zero to Testing
PPTX
Simple Proxying in Rails
PDF
Selecting a Web Framework
PPTX
Zero to Testing in JavaScript
PDF
Feminism & Open Source Contribution
PDF
Sadia Afroz: Detecting Hoaxes, Frauds, and Deception in Writing Style Online
PDF
WordPress 101 Sunday Session
PPT
Css Best Practices
MidwestJS Zero to Testing
Simple Proxying in Rails
Selecting a Web Framework
Zero to Testing in JavaScript
Feminism & Open Source Contribution
Sadia Afroz: Detecting Hoaxes, Frauds, and Deception in Writing Style Online
WordPress 101 Sunday Session
Css Best Practices

Similar to Displacing Worst Practices in CSS (20)

PPT
Css Best Practices
PDF
Scalable CSS You and Your Back-End Coders Can Love - @CSSConf Asia 2014
KEY
The Cascade, Grids, Headings, and Selectors from an OOCSS Perspective, Ajax ...
PPT
How Cascading Style Sheets (CSS) Works
PDF
Structuring your CSS for maintainability: rules and guile lines to write CSS
PPTX
Your CSS is Awesome
PPTX
Charlotte FED - CSS Inheritance and Specificity
PDF
Modular HTML & CSS Turbo Workshop
PPTX
Html Css Mistakes
PPT
Make Css easy(part:2) : easy tips for css(part:2)
PPTX
Html and CSS 101 - hipages Group Friday talk
PDF
6 Steps to Make Your CSS Code More Maintainable
PDF
CSS Best practice
PDF
Maintainable CSS
PPT
css_and_html_coding_today-ted_ulle.ppt
PDF
Modular HTML & CSS Workshop
PDF
Front-End Methodologies
KEY
The Fast And The Fabulous
PPT
Basics Of Css And Some Common Mistakes
Css Best Practices
Scalable CSS You and Your Back-End Coders Can Love - @CSSConf Asia 2014
The Cascade, Grids, Headings, and Selectors from an OOCSS Perspective, Ajax ...
How Cascading Style Sheets (CSS) Works
Structuring your CSS for maintainability: rules and guile lines to write CSS
Your CSS is Awesome
Charlotte FED - CSS Inheritance and Specificity
Modular HTML & CSS Turbo Workshop
Html Css Mistakes
Make Css easy(part:2) : easy tips for css(part:2)
Html and CSS 101 - hipages Group Friday talk
6 Steps to Make Your CSS Code More Maintainable
CSS Best practice
Maintainable CSS
css_and_html_coding_today-ted_ulle.ppt
Modular HTML & CSS Workshop
Front-End Methodologies
The Fast And The Fabulous
Basics Of Css And Some Common Mistakes
Ad

More from pamselle (11)

PDF
WordPress 101 Saturday Session
PDF
Power Spriting With Compass
PPT
Aylin Caliskan: Quantifying the Translator Effect: Identifying authors and ma...
PDF
Kamelia Aryafar: Musical Genre Classification Using Sparsity-Eager Support Ve...
PDF
GDI WordPress 4 January 2012 (white)
PDF
GDI WordPress 4 January 2012
PDF
GDI WordPress 3 January 2012 (white background)
PDF
GDI WordPress 3 January 2012
PDF
GDI WordPress 2 January 2012
PDF
Gdi word press_2
PDF
GDI WordPress 1 January 2012
WordPress 101 Saturday Session
Power Spriting With Compass
Aylin Caliskan: Quantifying the Translator Effect: Identifying authors and ma...
Kamelia Aryafar: Musical Genre Classification Using Sparsity-Eager Support Ve...
GDI WordPress 4 January 2012 (white)
GDI WordPress 4 January 2012
GDI WordPress 3 January 2012 (white background)
GDI WordPress 3 January 2012
GDI WordPress 2 January 2012
Gdi word press_2
GDI WordPress 1 January 2012
Ad

Recently uploaded (20)

PDF
Machine learning based COVID-19 study performance prediction
PPTX
Understanding_Digital_Forensics_Presentation.pptx
PDF
KodekX | Application Modernization Development
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PDF
Approach and Philosophy of On baking technology
PPT
Teaching material agriculture food technology
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PDF
Unlocking AI with Model Context Protocol (MCP)
PDF
Encapsulation_ Review paper, used for researhc scholars
DOCX
The AUB Centre for AI in Media Proposal.docx
PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PPTX
Big Data Technologies - Introduction.pptx
PDF
Shreyas Phanse Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...
PDF
cuic standard and advanced reporting.pdf
PPTX
Cloud computing and distributed systems.
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
Machine learning based COVID-19 study performance prediction
Understanding_Digital_Forensics_Presentation.pptx
KodekX | Application Modernization Development
Per capita expenditure prediction using model stacking based on satellite ima...
Approach and Philosophy of On baking technology
Teaching material agriculture food technology
Chapter 3 Spatial Domain Image Processing.pdf
The Rise and Fall of 3GPP – Time for a Sabbatical?
20250228 LYD VKU AI Blended-Learning.pptx
Unlocking AI with Model Context Protocol (MCP)
Encapsulation_ Review paper, used for researhc scholars
The AUB Centre for AI in Media Proposal.docx
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
Big Data Technologies - Introduction.pptx
Shreyas Phanse Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...
cuic standard and advanced reporting.pdf
Cloud computing and distributed systems.
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
Agricultural_Statistics_at_a_Glance_2022_0.pdf

Displacing Worst Practices in CSS