acss: rethinking css best practices

109
Renato Iwashima @renatoiwa Rethinking CSS Best Practices Thursday, October 24, 13

Upload: renatoiwa

Post on 27-Jan-2015

145 views

Category:

Technology


17 download

DESCRIPTION

When it comes to CSS, the "sanctity" of the Separation of Concerns principle (SoC) has lead us to accept bloat, obsolescence, redundancy, poor caching, and more. We're introducing a new CSS architecture that we called "Atomic CSS". It challenges best practices to address many of these common issues.

TRANSCRIPT

Page 1: ACSS: Rethinking CSS Best Practices

Renato Iwashima@renatoiwa

Rethinking CSS Best Practices

Thursday, October 24, 13

Page 2: ACSS: Rethinking CSS Best Practices

The Separation of Concerns

Image by Les_Stockton on

Thursday, October 24, 13

Page 3: ACSS: Rethinking CSS Best Practices

Thursday, October 24, 13

Page 4: ACSS: Rethinking CSS Best Practices

HTML

Javascript

CSS

Thursday, October 24, 13

Page 5: ACSS: Rethinking CSS Best Practices

Thursday, October 24, 13

Page 6: ACSS: Rethinking CSS Best Practices

<div class="my-module"> <h2 class="headline">Headline</h2> <h3 class="subhead">Subhead</h3> <div class="body">Body</div></div>

Thursday, October 24, 13

Page 7: ACSS: Rethinking CSS Best Practices

<div class="my-module"> <h2 class="headline">Headline</h2> <h3 class="subhead">Subhead</h3> <div class="body">Body</div></div>

.my-module {! background: whiteSmoke;! padding: 10px;}

Thursday, October 24, 13

Page 8: ACSS: Rethinking CSS Best Practices

<div class="my-module"> <h2 class="headline">Headline</h2> <h3 class="subhead">Subhead</h3> <div class="body">Body</div></div>

.my-module {! background: whiteSmoke;! padding: 10px;}

.my-module .headline { font-size: 20px; font-weight: bold; border-bottom: 1px dotted #333;}

Thursday, October 24, 13

Page 9: ACSS: Rethinking CSS Best Practices

<div class="my-module"> <h2 class="headline">Headline</h2> <h3 class="subhead">Subhead</h3> <div class="body">Body</div></div>

.my-module {! background: whiteSmoke;! padding: 10px;}

.my-module .headline { font-size: 20px; font-weight: bold; border-bottom: 1px dotted #333;}

.my-module .subhead { font-size: 16px; font-weight: 200;}

Thursday, October 24, 13

Page 10: ACSS: Rethinking CSS Best Practices

<div class="my-module"> <h2 class="headline">Headline</h2> <h3 class="subhead">Subhead</h3> <div class="body">Body</div></div>

.my-module {! background: whiteSmoke;! padding: 10px;}

.my-module .headline { font-size: 20px; font-weight: bold; border-bottom: 1px dotted #333;}

.my-module .subhead { font-size: 16px; font-weight: 200;}

.my-module .body { padding: 10px;}

Thursday, October 24, 13

Page 11: ACSS: Rethinking CSS Best Practices

Thursday, October 24, 13

Page 12: ACSS: Rethinking CSS Best Practices

Thursday, October 24, 13

Page 13: ACSS: Rethinking CSS Best Practices

.my-module {! background: whiteSmoke;! padding: 10px;}.my-module .headline { font-size: 20px; font-weight: bold; border-bottom: 1px dotted #333;}.my-module .subhead { font-size: 16px; font-weight: 200;}.my-module .body { padding: 10px;}

<div class="mymodule"> <h2 class="headline">Headline</h2> <h3 class="subhead">Subhead</h3> <div class="body"> <p>Body text</p> </div></div>

Thursday, October 24, 13

Page 14: ACSS: Rethinking CSS Best Practices

.my-module {! background: whiteSmoke;! padding: 10px;}.my-module .headline { font-size: 20px; font-weight: bold; border-bottom: 1px dotted #333;}.my-module .subhead { font-size: 16px; font-weight: 200;}.my-module .body { padding: 10px;}

<div class="mymodule"> <h2 class="headline">Headline</h2> <h3 class="subhead">Subhead</h3> <div class="body"> <p>Body text</p>

<h4 class="subsubhead">Subsubhead</h4><p>Body text</p>

</div></div>

Thursday, October 24, 13

Page 15: ACSS: Rethinking CSS Best Practices

.my-module {! background: whiteSmoke;! padding: 10px;}.my-module .headline { font-size: 20px; font-weight: bold; border-bottom: 1px dotted #333;}.my-module .subhead { font-size: 16px; font-weight: 200;}.my-module .body { padding: 10px;}.my-module .subsubhead { border-bottom: 1px dotted #333;}

<div class="mymodule"> <h2 class="headline">Headline</h2> <h3 class="subhead">Subhead</h3> <div class="body"> <p>Body text</p>

<h4 class="subsubhead">Subsubhead</h4><p>Body text</p>

</div></div>

Thursday, October 24, 13

Page 16: ACSS: Rethinking CSS Best Practices

.my-module {! background: whiteSmoke;! padding: 10px;}.my-module .headline { font-size: 20px; font-weight: bold; border-bottom: 1px dotted #333;}.my-module .subhead { font-size: 16px; font-weight: 200;}.my-module .body { padding: 10px;}.my-module .subsubhead { border-bottom: 1px dotted #333;}

<div class="mymodule"> <h2 class="headline">Headline</h2> <h3 class="subhead">Subhead</h3> <div class="body"> <p>Body text</p>

<h4 class="subsubhead">Subsubhead</h4><p>Body text</p>

</div></div>

Thursday, October 24, 13

Page 17: ACSS: Rethinking CSS Best Practices

.my-module {! background: whiteSmoke;! padding: 10px;}.my-module .headline { font-size: 20px; font-weight: bold; border-bottom: 1px dotted #333;}.my-module .subhead { font-size: 16px; font-weight: 200;}.my-module .body { padding: 10px;}.my-module .subsubhead { border-bottom: 1px dotted #333;}

<div class="mymodule"> <h2 class="headline">Headline</h2> <h3 class="subhead">Subhead</h3> <div class="body"> <p>Body text</p>

<h4 class="subsubhead">Subsubhead</h4><p>Body text</p>

</div></div>

Growth

Thursday, October 24, 13

Page 18: ACSS: Rethinking CSS Best Practices

0

<div class="mymodule"> <h2 class="headline">Headline</h2> <h3 class="subhead">Subhead</h3> <div class="body"> <p>Body text</p> <h4 class="subsubhead">Subsubhead</h4> <p>Body text</p> </div></div>

.mymodule {! background: whiteSmoke;! padding: 10px;}.mymodule .headline { font-size: 20px; font-weight: bold;}.mymodule .subhead { font-size: 16px; font-weight: 200;}.mymodule .body { padding: 10px;}

.mymodule .headline,

.mymodule .subsubhead { border-bottom: 1px dotted #333;}

Thursday, October 24, 13

Page 19: ACSS: Rethinking CSS Best Practices

.my-module .headline,

.my-module .subsubhead { border-bottom: 1px dotted #333;}

Thursday, October 24, 13

Page 20: ACSS: Rethinking CSS Best Practices

.my-module .headline,

.my-module .subsubhead,

.something-else-001 { border-bottom: 1px dotted #333;}

Thursday, October 24, 13

Page 21: ACSS: Rethinking CSS Best Practices

.my-module .headline,

.my-module .subsubhead,

.something-else-001,

.something-else-002 { border-bottom: 1px dotted #333;}

Thursday, October 24, 13

Page 22: ACSS: Rethinking CSS Best Practices

.my-module .headline,

.my-module .subsubhead,

.something-else-001,

.something-else-002,

.something-else-003,

.something-else-004,

.something-else-005,

.something-else-006,

.something-else-007,

.something-else-008,

.something-else-009,

.something-else-010,

.something-else-011,

.something-else-012 { border-bottom: 1px dotted #333;}

Thursday, October 24, 13

Page 23: ACSS: Rethinking CSS Best Practices

.heading { border-bottom: 1px dotted #333;}

Thursday, October 24, 13

Page 24: ACSS: Rethinking CSS Best Practices

.heading

.heading

Thursday, October 24, 13

Page 25: ACSS: Rethinking CSS Best Practices

.heading

.heading

Thursday, October 24, 13

Page 26: ACSS: Rethinking CSS Best Practices

.my-module .headline { border-bottom-color: red;}

Thursday, October 24, 13

Page 27: ACSS: Rethinking CSS Best Practices

.my-module .headline { border-bottom-color: red;}.page-1 .my-module .headline { border-bottom-color: navy;}

Thursday, October 24, 13

Page 28: ACSS: Rethinking CSS Best Practices

.my-module .headline { border-bottom-color: red;}.page-1 .my-module .headline { border-bottom-color: navy;}

.page-2 .my-module .headline { border-bottom-color: orange;}

Thursday, October 24, 13

Page 29: ACSS: Rethinking CSS Best Practices

.my-module .headline { border-bottom-color: red;}.page-1 .my-module .headline { border-bottom-color: navy;}

.page-2 .my-module .headline { border-bottom-color: orange;}

Growth

Thursday, October 24, 13

Page 30: ACSS: Rethinking CSS Best Practices

.my-module .headline { border-bottom-color: red;}.page-1 .my-module .headline { border-bottom-color: navy;}

.page-2 .my-module .headline { border-bottom-color: orange;}

Specificity

Growth

Thursday, October 24, 13

Page 31: ACSS: Rethinking CSS Best Practices

Header

Module 1 Module 2

Module 4

Module 6

Module 3

Module 5

Footer

Current UI Page Architecture

Thursday, October 24, 13

Page 32: ACSS: Rethinking CSS Best Practices

Header

Module 1 Module 2

Module 4

Module 6

Module 3

Module 5

Normalize

Footer

Current UI Page Architecture

Thursday, October 24, 13

Page 33: ACSS: Rethinking CSS Best Practices

Header

Module 1 Module 2

Module 4

Module 6

Module 3

Module 5

Normalize Layout

Footer

Current UI Page Architecture

Thursday, October 24, 13

Page 34: ACSS: Rethinking CSS Best Practices

Header

Module 1 Module 2

Module 4

Module 6

Module 3

Module 5

Normalize Layout Reusable Patterns

Footer

Current UI Page Architecture

Thursday, October 24, 13

Page 35: ACSS: Rethinking CSS Best Practices

Header

Module 1 Module 2

Module 4

Module 6

Module 3

Module 5

Module 1 CSS

Normalize Layout Reusable Patterns

Module 3 CSS

Module 5 CSS

Module 2 CSS

Module 4 CSS

Module 6 CSS

Footer

Current UI Page Architecture

Thursday, October 24, 13

Page 36: ACSS: Rethinking CSS Best Practices

Current UI Architecture on Multiple Pages

Header

Module 1 Module 2

Module 4

Module 6

Module 3

Module 5

Footer

Header

Module 1 Module 4

Module 6Module 5

Footer

Header

Module 1

Module 6

Module 5

Footer

Header

Module 1

Module 2

Module 6

Module 3

Footer

Thursday, October 24, 13

Page 37: ACSS: Rethinking CSS Best Practices

NORMALIZE

Current UI Architecture on Multiple Pages

Header

Module 1 Module 2

Module 4

Module 6

Module 3

Module 5

Footer

Header

Module 1 Module 4

Module 6Module 5

Footer

Header

Module 1

Module 6

Module 5

Footer

Header

Module 1

Module 2

Module 6

Module 3

Footer

Thursday, October 24, 13

Page 38: ACSS: Rethinking CSS Best Practices

REUSABLE PATTERNS

NORMALIZE

Current UI Architecture on Multiple Pages

Header

Module 1 Module 2

Module 4

Module 6

Module 3

Module 5

Footer

Header

Module 1 Module 4

Module 6Module 5

Footer

Header

Module 1

Module 6

Module 5

Footer

Header

Module 1

Module 2

Module 6

Module 3

Footer

Thursday, October 24, 13

Page 39: ACSS: Rethinking CSS Best Practices

REUSABLE PATTERNS

NORMALIZE

Current UI Architecture on Multiple Pages

Header

Module 1 Module 2

Module 4

Module 6

Module 3

Module 5

Footer

Header

Module 1 Module 4

Module 6Module 5

Footer

Header

Module 1

Module 6

Module 5

Footer

Header

Module 1

Module 2

Module 6

Module 3

Footer

MODULE 1 CSS

PAGE SPECIFIC STYLES

MODULE 2 CSS

MODULE 3 CSS

MODULE 4 CSS

MODULE 5 CSS

MODULE 6 CSS

PAGE SPECIFIC STYLES

MODULE 1 CSS

MODULE 4 CSS

MODULE 5 CSS

MODULE 6 CSS

PAGE SPECIFIC STYLES

MODULE 1 CSS

MODULE 5 CSS

MODULE 6 CSS

PAGE SPECIFIC STYLES

MODULE 1 CSS

MODULE 2 CSS

MODULE 3 CSS

MODULE 6 CSS

Thursday, October 24, 13

Page 40: ACSS: Rethinking CSS Best Practices

Poor caching from page to pageLimited reusability of stylesSpecificity warsContextual selectors used to scope stylesBloat!

Large Scale Websites Modularity

Thursday, October 24, 13

Page 41: ACSS: Rethinking CSS Best Practices

Where we want to be

Header

Module 1 Module 2

Module 4

Module 6

Module 3

Module 5

Footer

Header

Module 1 Module 4

Module 6Module 5

Footer

Header

Module 1

Module 6

Module 5

Footer

Header

Module 1

Module 2

Module 6

Module 3

Footer

MODULE 1 CSS

MODULE 2 CSS

MODULE 3 CSS

MODULE 4 CSS

MODULE 5 CSS

MODULE 6 CSS

MODULE 1 CSS

MODULE 4 CSS

MODULE 5 CSS

MODULE 6 CSS

MODULE 1 CSS

MODULE 5 CSS

MODULE 6 CSS

REUSABLE PATTERNS

NORMALIZE

PAGE SPECIFIC STYLES PAGE SPECIFIC STYLES PAGE SPECIFIC STYLES PAGE SPECIFIC STYLES

MODULE 1 CSS

MODULE 2 CSS

MODULE 3 CSS

MODULE 6 CSS

Thursday, October 24, 13

Page 42: ACSS: Rethinking CSS Best Practices

Where we want to be

Header

Module 1 Module 2

Module 4

Module 6

Module 3

Module 5

Footer

Header

Module 1 Module 4

Module 6Module 5

Footer

Header

Module 1

Module 6

Module 5

Footer

Header

Module 1

Module 2

Module 6

Module 3

Footer

MODULE 1 CSS

MODULE 2 CSS

MODULE 3 CSS

MODULE 4 CSS

MODULE 5 CSS

MODULE 6 CSS

MODULE 1 CSS

MODULE 4 CSS

MODULE 5 CSS

MODULE 6 CSS

MODULE 1 CSS

MODULE 5 CSS

MODULE 6 CSS

REUSABLE PATTERNS

NORMALIZE

PAGE SPECIFIC STYLES PAGE SPECIFIC STYLES PAGE SPECIFIC STYLES PAGE SPECIFIC STYLES

MODULE 1 CSS

MODULE 2 CSS

MODULE 3 CSS

MODULE 6 CSS

Thursday, October 24, 13

Page 43: ACSS: Rethinking CSS Best Practices

Semantic Class Names

Thursday, October 24, 13

Page 44: ACSS: Rethinking CSS Best Practices

Other than microformats,class names are used for presentational

purpose or javascript hooks.

Thursday, October 24, 13

Page 45: ACSS: Rethinking CSS Best Practices

Let’s talk aboutSemantic Class Names

Thursday, October 24, 13

Page 46: ACSS: Rethinking CSS Best Practices

se·man·ticadjective

1. relating to meaning in language or logic.

Thursday, October 24, 13

Page 47: ACSS: Rethinking CSS Best Practices

.titlebold large text

Thursday, October 24, 13

Page 48: ACSS: Rethinking CSS Best Practices

.bold and .largebold large text

Thursday, October 24, 13

Page 49: ACSS: Rethinking CSS Best Practices

.text-left { text-align: left; }

.text-right { text-align: right; }

.text-center { text-align: center; }

.pull-right { float: right !important; }

.pull-left { float: left !important; }

.affix { position: fixed; }

.invisible { visibility: hidden; }

.hidden { display: none !important;}

Bootstrap

Thursday, October 24, 13

Page 50: ACSS: Rethinking CSS Best Practices

.text-left { text-align: left !important; }

.text-right { text-align: right !important; }

.text-center { text-align: center !important; }

.text-justify { text-align: justify !important; }

.left { float: left !important; }

.right { float: right !important; }

.hide { display: none; }

Foundation

Thursday, October 24, 13

Page 51: ACSS: Rethinking CSS Best Practices

But we usually stop short since best practices is to

style elements using classes related to content.

Thursday, October 24, 13

Page 52: ACSS: Rethinking CSS Best Practices

BUT WHY?

Thursday, October 24, 13

Page 53: ACSS: Rethinking CSS Best Practices

CSS maintenance

Maintenance

Thursday, October 24, 13

Page 54: ACSS: Rethinking CSS Best Practices

Same HTML: Crawling optimizationAWD: Vary HTTP header

Responsive Page Grid

SEO & Responsive Web Design

Thursday, October 24, 13

Page 55: ACSS: Rethinking CSS Best Practices

... authors are encouraged to use [class attribute] values that describe the nature of the content, rather than values that describe the desired presentation of the content.

HTML5 specification section on classes

Thursday, October 24, 13

Page 56: ACSS: Rethinking CSS Best Practices

Nicolas Gallagher

About HTML Semantics Front End Architecturehttp://nicolasgallagher.com/about-html-semantics-front-end-architecture/

Thursday, October 24, 13

Page 57: ACSS: Rethinking CSS Best Practices

...there is no inherent reason to do this. In fact, it’s often a hindrance when working on large websites or applications.

Thursday, October 24, 13

Page 58: ACSS: Rethinking CSS Best Practices

The most reusable components are those with class names that are independent of the content.

Thursday, October 24, 13

Page 59: ACSS: Rethinking CSS Best Practices

Class names should communicate useful information to developers

Thursday, October 24, 13

Page 60: ACSS: Rethinking CSS Best Practices

Wilson Page

Building the new financial times web apphttp://coding.smashingmagazine.com/2013/05/23/building-the-new-financial-times-web-app/

Thursday, October 24, 13

Page 61: ACSS: Rethinking CSS Best Practices

Components need to be dumb, they can’t know anything of their context, or the consequences of any interactions that may occur within them.

Thursday, October 24, 13

Page 62: ACSS: Rethinking CSS Best Practices

<div class="apple"> <h2 class="apple_headline">{{headline}}</h2> <h3 class="apple_sub-head">{{subhead}}</h3> <div class="apple_body">{{body}}</div></div>

.apple_headline { font-size: 40px;}.apple_sub-head { font-size: 20px;}.apple_body { font-size: 14px; column-count: 2; color: #333;}

Fruit Classes

Thursday, October 24, 13

Page 63: ACSS: Rethinking CSS Best Practices

ReusableHard to know what the class is for

Thursday, October 24, 13

Page 64: ACSS: Rethinking CSS Best Practices

Nicole Sullivan

Our Best Practices Are Killing Ushttp://www.stubbornella.org/content/2011/04/28/our-best-practices-are-killing-us/

Thursday, October 24, 13

Page 65: ACSS: Rethinking CSS Best Practices

RedundancyBloatSpecificity wars

Thursday, October 24, 13

Page 66: ACSS: Rethinking CSS Best Practices

Keep specificity as low as possible and abstract repeating visual patterns

Thursday, October 24, 13

Page 67: ACSS: Rethinking CSS Best Practices

Treat code like Lego. Break code into the smallest little blocks possible.smashing magazine - @csswizardry (via @stubbornella) #btconf

Thursday, October 24, 13

Page 68: ACSS: Rethinking CSS Best Practices

Atomic CSS

Image by Alexey Vinokurov on

Thursday, October 24, 13

Page 69: ACSS: Rethinking CSS Best Practices

a·tom·icadjective

1. of or forming a single irreducible unit or component in a larger system

Thursday, October 24, 13

Page 70: ACSS: Rethinking CSS Best Practices

Class names inspired by Zen Coding (Emmet)

Thursday, October 24, 13

Page 71: ACSS: Rethinking CSS Best Practices

.Fl-start { float: left; }

.Fl-end { float: right; }

.Fl-n { float: none; }

.Cur-p { cursor: pointer; }

.Fz-l { font-size: 18px; }

.Fz-xl { font-size: 20px; }

.Mstart-10 { margin-left: 10px; } /* wOOt */

Thursday, October 24, 13

Page 72: ACSS: Rethinking CSS Best Practices

How can your design evolve?

Thursday, October 24, 13

Page 73: ACSS: Rethinking CSS Best Practices

Switching context:Instead of stylesheets you would

be managing templates.

Thursday, October 24, 13

Page 74: ACSS: Rethinking CSS Best Practices

Node.js and the new web front-endNicholas Zakas

Thursday, October 24, 13

Page 75: ACSS: Rethinking CSS Best Practices

Thursday, October 24, 13

Page 76: ACSS: Rethinking CSS Best Practices

<template>

Thursday, October 24, 13

Page 77: ACSS: Rethinking CSS Best Practices

Possibly coming in the future

Thursday, October 24, 13

Page 78: ACSS: Rethinking CSS Best Practices

<details open> <summary>Timepieces</summary> <ul> <li>Sundial</li> <li>Cuckoo clock</li> <li>Wristwatch</li> </ul></details>

<details open> <a id="summary"> &blacktriangledown; <summary>Timepieces</summary> </a> <ul> <li>Sundial</li> <li>Cuckoo clock</li> <li>Wristwatch</li> </ul></details>

Thursday, October 24, 13

Page 79: ACSS: Rethinking CSS Best Practices

<decorator id="details-open"> <template> <a id="summary"> &blacktriangledown; <content select="summary"></content> </a> <content></content> </template></decorator>

details[open] { decorator: url(#details-open); }

Thursday, October 24, 13

Page 80: ACSS: Rethinking CSS Best Practices

What goes into my stylesheet?

Thursday, October 24, 13

Page 81: ACSS: Rethinking CSS Best Practices

Basic rules like floating an elementHelper classes

Thursday, October 24, 13

Page 82: ACSS: Rethinking CSS Best Practices

/** * one liner with ellipsis * 1. we inherit hyphens:auto from body which would break "Ell" in table cells */.Ell { max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; -webkit-hyphens: none; /* 1 */ -ms-hyphens: none; -o-hyphens: none; hyphens: none;}/** * kinda line-clamp * 2 lines according to default font-size/line-height */.LineClamp { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; font-size: 13px; line-height: 1.25; max-height: 32px; _height: 32px; overflow: hidden;}

Thursday, October 24, 13

Page 83: ACSS: Rethinking CSS Best Practices

Reduces style scope

Reduces stylesheets bloat

Improves performance

Removes dependencies

Allows to share content and assets easily

Leverages cache by being immutable

Facilitates RTL/LTR interface switch

Thursday, October 24, 13

Page 84: ACSS: Rethinking CSS Best Practices

Use Case

Media Object

Thursday, October 24, 13

Page 85: ACSS: Rethinking CSS Best Practices

<div class="media"> <a class="pull-left" href="#">...</a> <div class="media-body">...</div></div>

FlBFC

Conventional

Thursday, October 24, 13

Page 86: ACSS: Rethinking CSS Best Practices

Fl BFC Fl

Media object?

3 Column Page Layout

Thursday, October 24, 13

Page 87: ACSS: Rethinking CSS Best Practices

<div class="Bfc"> <a class="Fl-start" href="#">...</a> <div class="Bfc">...</div></div>

FlBFC

Atomic

Thursday, October 24, 13

Page 88: ACSS: Rethinking CSS Best Practices

<div class="Bfc"> <div class="Fl-start">...</div> <div class="Fl-end">...</div> <div class="Bfc">...</div></div>

Fl BFC Fl

Atomic

Thursday, October 24, 13

Page 89: ACSS: Rethinking CSS Best Practices

Atomic

<div class="Bfc"> <div class="Fl-start">...</div> <div class="Fl-end">...</div></div><p>...</p>

Fl Fl

Thursday, October 24, 13

Page 90: ACSS: Rethinking CSS Best Practices

Use Case

Hero Unit

Thursday, October 24, 13

Page 91: ACSS: Rethinking CSS Best Practices

<div class="hero-unit"> <h1>Heading</h1> <p>Tagline</p></div>

Conventional

Thursday, October 24, 13

Page 92: ACSS: Rethinking CSS Best Practices

<h1 class="Fz-xl Fw-b">Heading</h1><p class="Fz-l Fw-200">Tagline</p>

Atomic

Thursday, October 24, 13

Page 93: ACSS: Rethinking CSS Best Practices

Reusable

It has a real meaning

Just by looking at the markup you already

know how it will look like

Thursday, October 24, 13

Page 94: ACSS: Rethinking CSS Best Practices

CSS bloat vs HTML bloat

Image by NASA Goddard Space Flight Center on

Thursday, October 24, 13

Page 95: ACSS: Rethinking CSS Best Practices

The data needs to live somewhere

Thursday, October 24, 13

Page 96: ACSS: Rethinking CSS Best Practices

.wrapper vs .bfc

Thursday, October 24, 13

Page 97: ACSS: Rethinking CSS Best Practices

.M-1 {margin: 1px;}

.M-2 {margin: 2px;}

.M-4 {margin: 4px;}

.M-6 {margin: 6px;}

.M-8 {margin: 8px;}

Good gzip compression

Thursday, October 24, 13

Page 98: ACSS: Rethinking CSS Best Practices

Measurements

Study Compressed Uncompressed

News 67.0 KB 267 KB

Sports 61.4 KB 230 KB

ACSS 38.3 KB 154 KB

Thursday, October 24, 13

Page 99: ACSS: Rethinking CSS Best Practices

Atomic vs Inline Styles

Image by MrMeik on

Thursday, October 24, 13

Page 100: ACSS: Rethinking CSS Best Practices

Specificity1.0.0.0

Verbosity

Scope

Portability

Specificity0.0.1.0

Abstraction

Mapping

Inline Styles ACSS

Thursday, October 24, 13

Page 101: ACSS: Rethinking CSS Best Practices

Real World Results

Thursday, October 24, 13

Page 102: ACSS: Rethinking CSS Best Practices

answers.yahoo.com 30.1KB

sports.yahoo.com 67.4KB

omg.yahoo.com 46.2KB

yahoo.com 45.9KB

Conventional

Atomic

my.yahoo.com 21.3KB (18KB + 3KB)

Thursday, October 24, 13

Page 103: ACSS: Rethinking CSS Best Practices

answers.yahoo.com 30.1KB

sports.yahoo.com 67.4KB

omg.yahoo.com 46.2KB

yahoo.com 45.9KB

Conventional

Atomic

my.yahoo.com 21.3KB (18KB + 3KB)

Reusable

Thursday, October 24, 13

Page 104: ACSS: Rethinking CSS Best Practices

One CSS

Thursday, October 24, 13

Page 105: ACSS: Rethinking CSS Best Practices

We’re not banning semantic classes

Thursday, October 24, 13

Page 106: ACSS: Rethinking CSS Best Practices

Re-evaluate the benefits of the common approach rather than adopt it as the de facto tool for

styling web pages.

Thursday, October 24, 13

Page 107: ACSS: Rethinking CSS Best Practices

Break code into the smallest presentational classes as possible

Thursday, October 24, 13

Page 108: ACSS: Rethinking CSS Best Practices

“Everything is changing too quickly for commandments that are etched in stone.

We all need to be open to new learnings, new approaches, new best practices and

we need to be able to share them.

Not rules, tools.”

http://notrulestools.com/

Thursday, October 24, 13

Page 109: ACSS: Rethinking CSS Best Practices

http://bit.ly/atomiccss

@renatoiwa@thierryk

@StevenRCarlson

Thursday, October 24, 13