My INSURER PTE LTD - Insurtech Innovation Award 2024
Sass Essentials at Mobile Camp LA
1. Building Mobile Web Apps
📱 with LESS / Sass / Stylus
Speed up your front-end workflow with CSS
preprocessors.
Mobile Camp Los Angeles
Jake Johnson
October 18, 2012
45. The Inception Rule
Don’t go more than 4 levels
deep.
http://thesassway.com/beginner/the-
inception-rule
The Problem:
body body { ... }
body div.content div.container { ... }
div.container body div.content div.container div.articles { ... }
div.content body div.content div.container div.articles > div.post { ... }
div.articles body div.content div.container div.articles > div.post div.title { ... }
& > div.post body div.content div.container div.articles > div.post div.title h1 { ... }
body div.content div.container div.articles > div.post div.title h1 a { ... }
div.title body div.content div.container div.articles > div.post div.content { ... }
h1 body div.content div.container div.articles > div.post div.content p { ... }
a body div.content div.container div.articles > div.post div.content ul { ... }
div.content body div.content div.container div.articles > div.post div.content ul li { ... }
body div.content div.container div.articles > div.post div.author { ... }
p
body div.content div.container div.articles > div.post div.author a.display { ... }
ul body div.content div.container div.articles > div.post div.author a.display img { ... }
li body div.content div.container div.articles > div.post div.author h4 { ... }
div.author body div.content div.container div.articles > div.post div.author h4 a { ... }
a.display body div.content div.container div.articles > div.post div.author p { ... }
body div.content div.container div.articles > div.post div.author p a { ... }
img body div.content div.container div.articles > div.post div.author ul { ... }
h4 body div.content div.container div.articles > div.post div.author ul li { ... }
a
p
a
46. The Inception Rule
“But the rendering performance and file size isn’t
that big of a deal.”
Your styles are chained to the DOM, making
maintenance more difficult.
1) Focus on reusability for different contexts.
2) Reduce the # of selectors as much as you can.
Lower File Size, Better Rendering Performance,
Easier Maintenance. Get in the habit!
47. Google’s Recommendations
Avoid a universal key selector.
Make your rules as specific as possible.
Class and ID selectors over tag selectors.
You can still use tag selectors, but try to make them top level.
Remove redundant qualifiers.
https://developers.google.com/speed/docs/best-practices/rendering#UseEfficientCSSSelectors
49. Google’s Recommendations
Avoid using descendant selectors, especially
those that specify redundant ancestors.
Use class selectors instead of descendant
selectors.
https://developers.google.com/speed/docs/best-practices/rendering#UseEfficientCSSSelectors
72. COMPASS MIXINS
Typography
Links Lists Text
Hover Link Bullets Ellipsis
Link Colors Horizontal List Force Wrap
Unstyled Link Inline-Block List No Wrap
Inline List Text Replacement
77. OOCSS Basic Tips
Don’t make your base element styles dependent
on its surrounding DOM.
Add semantic classes to elements and use Sass
placeholder patterns to skin.
You can still use IDs in your markup for
JavaScript. Use classes for reusability.