SlideShare a Scribd company logo
1 of 153
OBJECT-ORIENTED CSS
 scale to millions of users or thousands of pages
NICOLE SULLIVAN
  “stubbornella” on the web
SLIDES
http://www.slideshare.net/stubbornella
THE STATE OF CSS
THE “C” IN CSS
 understanding the cascade
BROWSER DEFAULT STYLES

❖   Browsers have internal default stylesheets
❖   They are all different



❖   Use reset.css from YUI to level the playing field
CLASS ORDER

<p class=”message error”>Borken!</p>




The order of the classes makes no difference.
ORDER OF THE PROPERTY
     VALUE PAIRS

 .foo{color: red; color: blue;}
BROWSER IGNORES BITS IT
 DOESN’T UNDERSTAND

 .foo{color: red; colour: blue;}
ORDER OF THE RULESETS


     .foo{color: red;}
     .foo{color: blue;}
ORDER OF THE
                 STYLESHEETS

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://
www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
  <link rel="stylesheet" type="text/css" href="styles.css" />
  <link rel="stylesheet" type="text/css" href="moreStyles.css" />
</head>
<body>
<p>My page</p>
</body>
</html>
SPECIFICITY?
Sort of like a game of poker
FROM THE SPEC:
❖   Count 1 if the declaration is from is a 'style' attribute rather
    than a rule with a selector, 0 otherwise (= a) (In HTML, values
    of an element's "style" attribute are style sheet rules. These
    rules have no selectors, so a=1, b=0, c=0, and d=0.)
❖   Count the number of ID attributes in the selector (= b)
❖   Count the number of other attributes and pseudo-classes in
    the selector (= c)
❖   Count the number of element names and pseudo-elements in
    the selector (= d)
IT GOES ON...

❖   The specificity is based only on the form of the selector. In
    particular, a selector of the form "[id=p33]" is counted as an
    attribute selector (a=0, b=0, c=1, d=0), even if the id attribute
    is defined as an "ID" in the source document's DTD.


❖   Concatenating the four numbers a-b-c-d (in a number system
    with a large base) gives the specificity.
ROUGHLY SPEAKING...
  We need to calculate specificity faster...
ID AND CLASS



#nav p{color: red }
.nav p{color: blue }
INLINE STYLES



<p style=”color: green;”>My page</p>
!IMPORTANT



p{color: red !important}
<p style=”color: green;”>My page</p>
CSS INHERITANCE

          body{font-size: 18px;}

          <body>
            <p>This text is 18px.</p>
          </body>




http://www.w3.org/TR/CSS2/propidx.html
AGGREGATION OF RULES


 <p class=”message error”>Boo</p>
 <p class=”message hint”>Boo</p>
 <p class=”message help”>Boo</p>
POWERFUL
misunderstanding of CSS has led to a mess...
CODE IS TOO FRAGILE.
Even the cleanest code gets ruined by the first non-expert to
                          touch it.
REQUIRE EXPERT ABILITY
 JUST TO GET STARTED.
     this is not a sign of maturity.
CODE RE-USE IS ALMOST
   NONEXISTENT
  people don’t trust other developers’ code.
FILE SIZE JUST KEEPS
    GETTING BIGGER
As the site evolves we continuously modify the CSS.
WHAT IS THE MOST
 IMPORTANT MISTAKE
TALENTED CODERS ARE
      MAKING?
    Writing really clever modules.
THE SIZE OF THEIR CSS
     WILL INCREASE
in a 1:1 relationship with the number of blocks, pages, and
                   complexity of content.
WHAT IS OBJECT-ORIENTED
         CSS?
     A philosophy? A framework? A tool?
MORE LIKE AN EVOLUTION
  OF THE LANGUAGE
      it makes CSS more powerful
HOW IS IT DIFFERENT?


          ul{...}
       ul li{...}
     ul li a{...}
HOW IS IT DIFFERENT?


                        ul{...}
                     ul li{...}
                   ul li a{...}



Until now, we focused all our effort here
HOW IS IT DIFFERENT?


                   ul{...}
                ul li{...}
              ul li a{...}



But, the architecture lives here
TERMINOLOGY CAN BE
    CONFUSING
so forget about a 1:1 mapping with either CSS or OOP
ALL OF THE CODE IS OPEN
  SOURCE: ON GITHUB
   http://wiki.github.com/stubbornella/oocss/
selector   heading   module   grid
selector   heading   template   grid
HEADINGS
 reusable Lego
Heading Level 1
                                Heading Level 2
   HEADINGS                     Heading Level 3
Getting the look and feel you
want with the semantics you     Heading Level 4
            need.
                                Heading Level 5

                                Heading Level 6
REUSING ELEMENTS
   MAKES THEM
    performance “freebies”
COMPONENTS
ARE LIKE LEGO
  Mix and match to create
diverse and interesting pages.
AVOID DUPLICATION
Wasting performance resources on components that can’t add
                          value.
NEARLY
 IDENTICAL
  MODULES
Headings 3 and 5 are too
         similar.
Rule of thumb:
If two modules look too similar to include on
the same page, they are too similar to include
together in a site, choose one!
AVOID LOCATION-
DEPENDENT STYLES
 Sandboxing is better than spaghetti,
 but leads to performance problems
AVOID WHAT?
FUNCTION AREA()
FUNCTION AREA()
FUNCTION AREA()
EVERY NOW AND THEN...
RETURNED DIAMETER
BROKEN.
IN CSS WE DO THIS
   ALL THE TIME
BROKEN.
A   Heading should not become a          Heading

          in another part of the page.
AVOID
                          EXAMPLE
             #weatherModule h3{color:red;}
             #tabs h3{color:blue}


❖   Global color undefined for h3, so it will be
    ‣   unstyled in new modules,
    ‣   developers forced to write more CSS for the same style
AVOID
                          EXAMPLE
             h3{color:black;}
             #weatherModule h3{color:red;}
             #tabs h3{color:blue}
❖   Global color defined (better!)
❖   Weather and tabs override default h3
    ‣   three styles for h3 cannot co-exist in the same module
    ‣   default style cannot be used in weather and tabs without costly
        overrides
❖   Weather and tabs h3 can never be used outside of those
    modules
CONSISTENCY
    Writing more rules to
overwrite the crazy rules from
           before.

 e.g. Heading should behave
 predictably in any module.
TRY THIS INSTEAD
                        h1,    .h1{...}
                        h2,    .h2{...}
                        h3,    .h3{...}
                        h4,    .h4{...}
                        h5,    .h5{...}
                        h6,    .h6{...}

❖   Global values defined
❖   Semantics respected (while allowing visual flexibility)

         <h3 class=”h6”>Heading</h3>
NEED MORE THAN 6
   HEADINGS?
 Really? Any duplicates? Any too similar?
STILL NEED MORE
                HEADINGS?
           .category{...}
           .section{...}
           .product{...}
           .prediction{...}

❖   Extend the heading object via a class on the object itself
❖   Avoid using the cascade to change display of nested objects
selector   heading   template   grid
TEMPLATE & GRIDS
Be flexible - extensible height and width
TEMPLATE


• 807   bytes

• 13   lines of code

• easily
      extended to custom
 page and column width
GRIDS
•   574 bytes

•   14 lines of code

•   Percentage widths adapt to
    different page sizes

•   Includes halfs, thirds, fourths, and
    fifths

•   No gutters

•   Infinite nesting and stacking
Grids
control the
  width
Content
controls
 height
FIXED DIMENSIONS
limit the ways in which a module can be reused
selector   heading   template   grid
TAMING SELECTORS
   sanity for our stylesheets
SIZE OF THE CSS FILE AND
 IMPLIED HTTP REQUESTS
   are the biggest factor for CSS performance
REFLOWS AND
RENDERING TIME
  are (much!) less important
DUPLICATION IS WORSE
  THAN STALE RULES
  because we have tools to deal with the latter
DEFINE DEFAULT VALUES
   Don’t repeat this code in every object
#weatherModule h3{color:red;}
#tabs h3{color:blue}




 DEFINE DEFAULT VALUES
       Don’t repeat this code in every object
X
#weatherModule h3{color:red;}
#tabs h3{color:blue}




 DEFINE DEFAULT VALUES
       Don’t repeat this code in every object
X
#weatherModule h3{color:red;}
#tabs h3{color:blue}




 DEFINE DEFAULT VALUES
       Don’t repeat this code in every object
               h1,    .h1{...}
               h2,    .h2{...}
               h3,    .h3{...}
               h4,    .h4{...}
               h5,    .h5{...}
               h6,    .h6{...}
DEFINE STRUCTURE IN A
   SEPARATE CLASS
   Don’t repeat this code in every object
                                       block
                                          inner
                                                  hd




                                                  bd




                                                  ft
div.error{...}




           STYLE CLASSES
                 rather than elements
X
div.error{...}




           STYLE CLASSES
                 rather than elements


 .error{           most of the code goes here   }
X
  div.error{...}




             STYLE CLASSES
                   rather than elements


   .error{           most of the code goes here   }
div.error{                                        }
  p.error{                  exceptions only       }
 em.error{                                        }
div{...}
 ul{...}
 p{..}




AVOID STYLING ELEMENTS
            unless defining defaults
div{...}
  X
 ul{...}
 p{..}




AVOID STYLING ELEMENTS
            unless defining defaults
               .error{...}
              .section{...}
             .products{...}
html body .myModule div .hd{...}
.myModule2 .hd {...}


          GIVE RULES THE
         SAME STRENGTH
      Use cascade order to overwrite previous rules
X
html body .myModule div .hd{...}
.myModule2 .hd {...}


          GIVE RULES THE
         SAME STRENGTH
      Use cascade order to overwrite previous rules



     .myModule .hd{...}
     .myModule2 .hd{...}
.mod .hd{...}
.ie .mod .hd{...}
.weatherMod .hd {...}




    USE HACKS SPARINGLY
       And don’t let them change your specificity
.mod .hd{...}
  X
.ie .mod .hd{...}
.weatherMod .hd {...}




    USE HACKS SPARINGLY
       And don’t let them change your specificity



     .mod .hd{color: red; _zoom:1;}
     .weatherMod .hd{...}
.sidebar ul{...}
.header ul {...}


      AVOID SPECIFYING
         LOCATION
      Apply classes to the object you wish to change
X
.sidebar ul{...}
.header ul {...}


      AVOID SPECIFYING
         LOCATION
      Apply classes to the object you wish to change



     .mainNav{...}
     .subNav {...}
AVOID OVERLY SPECIFIC
      CLASSES
    they’re all semantic, but limiting
AVOID OVERLY SPECIFIC
      CLASSES
     they’re all semantic, but limiting

 .vehicle{...}
 .motorcycle{...}
 .ducati{...}
 .ducatiMonster620{...}
 .nicolesDucatiMonster620{...}
AVOID OVERLY SPECIFIC
      CLASSES
     they’re all semantic, but limiting

 .vehicle{...}
 .motorcycle{...}
 .ducati{...}

   X
 .ducatiMonster620{...}
 .nicolesDucatiMonster620{...}
#myUniqueIdentifier{...}
   #myUniqueIdentifier2{...}




                       AVOID SINGLETONS
                       ids can only be used once in any given page




Source: Chris Griego
X
   #myUniqueIdentifier{...}
   #myUniqueIdentifier2{...}




                       AVOID SINGLETONS
                       ids can only be used once in any given page




Source: Chris Griego
Media
                 Subheading
                 Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna
                 aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis
                 aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat
                 cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.




                          USE MIXINS
                                 to avoid repeating code


Media Extended
Subheading
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna
aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis
aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat
cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
.inner{...}        .weatherMod .inner{...}
.tr{...}           .weatherMod .tr{...}
.bl{...}           .weatherMod .bl{...}



      ENCAPSULATION
     don’t access sub-nodes of an object directly



                          inner
.inner{...}
  X
                   .weatherMod .inner{...}
.tr{...}           .weatherMod .tr{...}
.bl{...}           .weatherMod .bl{...}



      ENCAPSULATION
     don’t access sub-nodes of an object directly



                          inner
OOCSS: A REAL LIFE
   EXAMPLE
         Gonzalo Cordero
  Front-End Engineer @Yahoo! inc.
Who
Who
Who
Who
TO SHARE
TO SHARE
TO SHARE
DESIGN CONSIDERATIONS
DESIGN CONSIDERATIONS


❖   Cross browser compatible
DESIGN CONSIDERATIONS


❖   Cross browser compatible
❖   Multi-language support
DESIGN CONSIDERATIONS


❖   Cross browser compatible
❖   Multi-language support
❖   Accessible
DESIGN CONSIDERATIONS


❖   Cross browser compatible
❖   Multi-language support
❖   Accessible
❖   Aggressive deadline to complete both layout and functionality
The Puzzle
The Puzzle
The Puzzle
The Puzzle
RESULT
WEB COMPROMISES
WEB COMPROMISES


❖   Why does the “easy” turn so complicated?
WEB COMPROMISES


❖   Why does the “easy” turn so complicated?
❖   Why do we need to compromise?
WEB COMPROMISES


❖   Why does the “easy” turn so complicated?
❖   Why do we need to compromise?
❖   Why can’t we rely on a set of solid rules and structures? Like
    other platforms do?
OOCSS SAVES THE DAY
OOCSS SAVES THE DAY

❖   Single simple markup structure
OOCSS SAVES THE DAY

❖   Single simple markup structure
❖   Cross browser support (even IE 5.5!)
OOCSS SAVES THE DAY

❖   Single simple markup structure
❖   Cross browser support (even IE 5.5!)
❖   Very minimum CSS
OOCSS SAVES THE DAY

❖   Single simple markup structure
❖   Cross browser support (even IE 5.5!)
❖   Very minimum CSS
❖   Scalable, easy to apply to multiple designs
OCSS SAVES THE DAY
OCSS SAVES THE DAY
OCSS SAVES THE DAY
OCSS SAVES THE DAY
OCSS SAVES THE DAY
AFTER OOCSS
TO CONTRIBUTE
Why can’t the web have great tools
 to build and design interfaces?
What’s stopping us?
CSSBUILDR

❖   If we said we could reuse the same structure over and over
    again, what’s stopping us from doing so?
❖   Different modules and page grids can be easily built.
❖   Plug and Play, Mix and Match.
CSSBUILDR: TECH SPECS


❖   Create and modify module contours, backgrounds, font-
    colors, etc.
❖   In two to three clicks you get a plug-and-play ready module
    that works cross browser.
❖   Built on top YUI.
THANK YOU
                   DEMO TIME


❖   ygonzalocordero@me.com
❖   Twitter: goonieiam
PHOTO CREDITS

Bernese Mountain Dog in a Suitcase by Sig20171

Family Outing by Jimbob

The fast and the furious Car Show by Rob Young

Young man and woman taking pictures of each other by RalphBijker

Motion Gears - team force by RalphBijker

Weighing In by Smig44_uk
PHOTO CREDITS
•   “South Carolina” by Army.Mil

•   “So Happy Together” by kalandrakas

•   “sometimes, a hug is all what we need” by kalandrakas

•   “Blueprint background” by Ricketts Fish

•   Spaghetti Monster

•   Food Photography - Spaghetti Tossed with Veg Oil

•   Spaghetti alla bolognese
PHOTO CREDITS
•   “You Crack Me Up” by http://flickr.com/photos/nickwheeleroz/2474196275/in/photostream/

•   “red lego” by http://flickr.com/photos/niznoz/5753993/

•   “Pablo’s cubism period began at three” by http://flickr.com/photos/wwworks/2475349116/in/set-72157608035966422/

•   “Kuwait water tower” by http://flickr.com/photos/asam/327911794/

•   idigit_teddy: http://www.flickr.com/photos/design_inspiration/238542495/

•   lucianvenutian: http://www.flickr.com/photos/lucianvenutian/1142630637/

•   Gimli_36: http://www.flickr.com/photos/navillot/1878124531/

•   NathanFromDeVryEET: http://www.flickr.com/photos/thatguyfromcchs08/2300190277/

•   Stabilo Boss: http://flickr.com/photos/stabilo-boss/101793494/in/set-72057594060779001/

•   Dead Man's Hand

•   Poker

•   Spaghetti & Meatballs
LET’S KEEP TALKING...
                http://stubbornella.org
               nicole@stubbornella.org
            “stubbornella” on the web...
      twitter, dopplr, slideshare, everywhere...

        http://github.com/stubbornella/oocss/
http://groups.google.com/group/object-oriented-css

More Related Content

What's hot

Rapid and Responsive - UX to Prototype with Bootstrap
Rapid and Responsive - UX to Prototype with BootstrapRapid and Responsive - UX to Prototype with Bootstrap
Rapid and Responsive - UX to Prototype with BootstrapJosh Jeffryes
 
ePub 3, HTML 5 & CSS 3 (+ Fixed-Layout)
ePub 3, HTML 5 & CSS 3 (+ Fixed-Layout)ePub 3, HTML 5 & CSS 3 (+ Fixed-Layout)
ePub 3, HTML 5 & CSS 3 (+ Fixed-Layout)Clément Wehrung
 
The Fast And The Fabulous
The Fast And The FabulousThe Fast And The Fabulous
The Fast And The FabulousNicole Sullivan
 
HTML5 & Friends
HTML5 & FriendsHTML5 & Friends
HTML5 & FriendsRemy Sharp
 
CSS: a rapidly changing world
CSS: a rapidly changing worldCSS: a rapidly changing world
CSS: a rapidly changing worldRuss Weakley
 
Killing the Angle Bracket
Killing the Angle BracketKilling the Angle Bracket
Killing the Angle Bracketjnewmanux
 
Html & Css presentation
Html  & Css presentation Html  & Css presentation
Html & Css presentation joilrahat
 
About Best friends - HTML, CSS and JS
About Best friends - HTML, CSS and JSAbout Best friends - HTML, CSS and JS
About Best friends - HTML, CSS and JSNaga Harish M
 
Efficient, maintainable CSS
Efficient, maintainable CSSEfficient, maintainable CSS
Efficient, maintainable CSSRuss Weakley
 
Doing more with LESS
Doing more with LESSDoing more with LESS
Doing more with LESSjsmith92
 
How to create a basic template
How to create a basic templateHow to create a basic template
How to create a basic templatevathur
 
Modular HTML, CSS, & JS Workshop
Modular HTML, CSS, & JS WorkshopModular HTML, CSS, & JS Workshop
Modular HTML, CSS, & JS WorkshopShay Howe
 
The Near Future of CSS
The Near Future of CSSThe Near Future of CSS
The Near Future of CSSRachel Andrew
 
Cascading Style Sheets - Part 02
Cascading Style Sheets - Part 02Cascading Style Sheets - Part 02
Cascading Style Sheets - Part 02Hatem Mahmoud
 
Front-End Methodologies
Front-End MethodologiesFront-End Methodologies
Front-End MethodologiesArash Manteghi
 
CSS Methodology
CSS MethodologyCSS Methodology
CSS MethodologyZohar Arad
 

What's hot (20)

CSS Grid Layout
CSS Grid LayoutCSS Grid Layout
CSS Grid Layout
 
Rapid and Responsive - UX to Prototype with Bootstrap
Rapid and Responsive - UX to Prototype with BootstrapRapid and Responsive - UX to Prototype with Bootstrap
Rapid and Responsive - UX to Prototype with Bootstrap
 
Html and Xhtml
Html and XhtmlHtml and Xhtml
Html and Xhtml
 
ePub 3, HTML 5 & CSS 3 (+ Fixed-Layout)
ePub 3, HTML 5 & CSS 3 (+ Fixed-Layout)ePub 3, HTML 5 & CSS 3 (+ Fixed-Layout)
ePub 3, HTML 5 & CSS 3 (+ Fixed-Layout)
 
The Fast And The Fabulous
The Fast And The FabulousThe Fast And The Fabulous
The Fast And The Fabulous
 
Css, xhtml, javascript
Css, xhtml, javascriptCss, xhtml, javascript
Css, xhtml, javascript
 
Taming CSS Selectors
Taming CSS SelectorsTaming CSS Selectors
Taming CSS Selectors
 
HTML5 & Friends
HTML5 & FriendsHTML5 & Friends
HTML5 & Friends
 
CSS: a rapidly changing world
CSS: a rapidly changing worldCSS: a rapidly changing world
CSS: a rapidly changing world
 
Killing the Angle Bracket
Killing the Angle BracketKilling the Angle Bracket
Killing the Angle Bracket
 
Html & Css presentation
Html  & Css presentation Html  & Css presentation
Html & Css presentation
 
About Best friends - HTML, CSS and JS
About Best friends - HTML, CSS and JSAbout Best friends - HTML, CSS and JS
About Best friends - HTML, CSS and JS
 
Efficient, maintainable CSS
Efficient, maintainable CSSEfficient, maintainable CSS
Efficient, maintainable CSS
 
Doing more with LESS
Doing more with LESSDoing more with LESS
Doing more with LESS
 
How to create a basic template
How to create a basic templateHow to create a basic template
How to create a basic template
 
Modular HTML, CSS, & JS Workshop
Modular HTML, CSS, & JS WorkshopModular HTML, CSS, & JS Workshop
Modular HTML, CSS, & JS Workshop
 
The Near Future of CSS
The Near Future of CSSThe Near Future of CSS
The Near Future of CSS
 
Cascading Style Sheets - Part 02
Cascading Style Sheets - Part 02Cascading Style Sheets - Part 02
Cascading Style Sheets - Part 02
 
Front-End Methodologies
Front-End MethodologiesFront-End Methodologies
Front-End Methodologies
 
CSS Methodology
CSS MethodologyCSS Methodology
CSS Methodology
 

Viewers also liked

Creating Living Style Guides to Improve Performance
Creating Living Style Guides to Improve PerformanceCreating Living Style Guides to Improve Performance
Creating Living Style Guides to Improve PerformanceNicole Sullivan
 
Building the Media Block in ReactJS
Building the Media Block in ReactJS Building the Media Block in ReactJS
Building the Media Block in ReactJS Nicole Sullivan
 
OOCSS presentation
OOCSS presentationOOCSS presentation
OOCSS presentationAndrew Ford
 
OOCSS in the Real World: A Case Study from the CBC
OOCSS in the Real World: A Case Study from the CBCOOCSS in the Real World: A Case Study from the CBC
OOCSS in the Real World: A Case Study from the CBCJamie Strachan
 
OOCSS in the Real World: A Case Study from the CBC - Revisited
OOCSS in the Real World: A Case Study from the CBC - RevisitedOOCSS in the Real World: A Case Study from the CBC - Revisited
OOCSS in the Real World: A Case Study from the CBC - RevisitedJamie Strachan
 
What's Object-Oriented CSS (japanese)
What's Object-Oriented CSS (japanese)What's Object-Oriented CSS (japanese)
What's Object-Oriented CSS (japanese)shinobu tsutsui
 
Object Oriented CSS - Joomla!dagen Nederland 2014
Object Oriented CSS - Joomla!dagen Nederland 2014Object Oriented CSS - Joomla!dagen Nederland 2014
Object Oriented CSS - Joomla!dagen Nederland 2014Babs Gösgens
 
Tech Headline - CSS Naming Conventions: Improve your code with OOCSS, SMACSS,...
Tech Headline - CSS Naming Conventions: Improve your code with OOCSS, SMACSS,...Tech Headline - CSS Naming Conventions: Improve your code with OOCSS, SMACSS,...
Tech Headline - CSS Naming Conventions: Improve your code with OOCSS, SMACSS,...Rodrigo Castilho
 
SITE 2009 - PowerPoint Games in a Secondary Laptop Environment
SITE 2009 - PowerPoint Games in a Secondary Laptop EnvironmentSITE 2009 - PowerPoint Games in a Secondary Laptop Environment
SITE 2009 - PowerPoint Games in a Secondary Laptop EnvironmentMichael Barbour
 
Lesson 1 jennifer bandico and analyn rollo
Lesson 1 jennifer bandico and analyn rolloLesson 1 jennifer bandico and analyn rollo
Lesson 1 jennifer bandico and analyn rolloJustino Cabarles
 
Evaluation 6
Evaluation 6Evaluation 6
Evaluation 6PhilP0612
 
Why should I care about information literacy?
Why should I care about information literacy? Why should I care about information literacy?
Why should I care about information literacy? nmjb
 
Educational computer games: what are the students’ expectations?
Educational computer games: what are the students’ expectations?Educational computer games: what are the students’ expectations?
Educational computer games: what are the students’ expectations?CITE
 

Viewers also liked (20)

Creating Living Style Guides to Improve Performance
Creating Living Style Guides to Improve PerformanceCreating Living Style Guides to Improve Performance
Creating Living Style Guides to Improve Performance
 
Object Oriented CSS
Object Oriented CSSObject Oriented CSS
Object Oriented CSS
 
Building the Media Block in ReactJS
Building the Media Block in ReactJS Building the Media Block in ReactJS
Building the Media Block in ReactJS
 
OOCSS presentation
OOCSS presentationOOCSS presentation
OOCSS presentation
 
OOCSS in the Real World: A Case Study from the CBC
OOCSS in the Real World: A Case Study from the CBCOOCSS in the Real World: A Case Study from the CBC
OOCSS in the Real World: A Case Study from the CBC
 
OOCSS in the Real World: A Case Study from the CBC - Revisited
OOCSS in the Real World: A Case Study from the CBC - RevisitedOOCSS in the Real World: A Case Study from the CBC - Revisited
OOCSS in the Real World: A Case Study from the CBC - Revisited
 
What's Object-Oriented CSS (japanese)
What's Object-Oriented CSS (japanese)What's Object-Oriented CSS (japanese)
What's Object-Oriented CSS (japanese)
 
CSS Wish List @JSConf
CSS Wish List @JSConfCSS Wish List @JSConf
CSS Wish List @JSConf
 
Object Oriented CSS - Joomla!dagen Nederland 2014
Object Oriented CSS - Joomla!dagen Nederland 2014Object Oriented CSS - Joomla!dagen Nederland 2014
Object Oriented CSS - Joomla!dagen Nederland 2014
 
Tech Headline - CSS Naming Conventions: Improve your code with OOCSS, SMACSS,...
Tech Headline - CSS Naming Conventions: Improve your code with OOCSS, SMACSS,...Tech Headline - CSS Naming Conventions: Improve your code with OOCSS, SMACSS,...
Tech Headline - CSS Naming Conventions: Improve your code with OOCSS, SMACSS,...
 
SITE 2009 - PowerPoint Games in a Secondary Laptop Environment
SITE 2009 - PowerPoint Games in a Secondary Laptop EnvironmentSITE 2009 - PowerPoint Games in a Secondary Laptop Environment
SITE 2009 - PowerPoint Games in a Secondary Laptop Environment
 
Questions to ask yourself before you advertise
Questions to ask yourself before you advertiseQuestions to ask yourself before you advertise
Questions to ask yourself before you advertise
 
Lesson 1 jennifer bandico and analyn rollo
Lesson 1 jennifer bandico and analyn rolloLesson 1 jennifer bandico and analyn rollo
Lesson 1 jennifer bandico and analyn rollo
 
Evaluation 6
Evaluation 6Evaluation 6
Evaluation 6
 
Mod4 l2.1
Mod4 l2.1Mod4 l2.1
Mod4 l2.1
 
Why should I care about information literacy?
Why should I care about information literacy? Why should I care about information literacy?
Why should I care about information literacy?
 
Mod4 l2.2
Mod4 l2.2Mod4 l2.2
Mod4 l2.2
 
Educational computer games: what are the students’ expectations?
Educational computer games: what are the students’ expectations?Educational computer games: what are the students’ expectations?
Educational computer games: what are the students’ expectations?
 
CSS Bloat!
CSS Bloat!CSS Bloat!
CSS Bloat!
 
TELLING THE TIME - PPT GAME
TELLING THE TIME - PPT GAMETELLING THE TIME - PPT GAME
TELLING THE TIME - PPT GAME
 

Similar to The Cascade, Grids, Headings, and Selectors from an OOCSS Perspective, Ajax Experience 2009

What is Object Oriented CSS?
What is Object Oriented CSS?What is Object Oriented CSS?
What is Object Oriented CSS?Nicole Sullivan
 
Display Suite: A Themers Perspective
Display Suite: A Themers PerspectiveDisplay Suite: A Themers Perspective
Display Suite: A Themers PerspectiveMediacurrent
 
Scalable CSS You and Your Back-End Coders Can Love - @CSSConf Asia 2014
Scalable CSS You and Your Back-End Coders Can Love - @CSSConf Asia 2014Scalable CSS You and Your Back-End Coders Can Love - @CSSConf Asia 2014
Scalable CSS You and Your Back-End Coders Can Love - @CSSConf Asia 2014Christian Lilley
 
The Future State of Layout
The Future State of LayoutThe Future State of Layout
The Future State of LayoutStephen Hay
 
Sass Essentials at Mobile Camp LA
Sass Essentials at Mobile Camp LASass Essentials at Mobile Camp LA
Sass Essentials at Mobile Camp LAJake Johnson
 
Building a Custom Theme in Drupal 8
Building a Custom Theme in Drupal 8Building a Custom Theme in Drupal 8
Building a Custom Theme in Drupal 8Anne Tomasevich
 
Spectrum 2015 going online with style - an intro to css
Spectrum 2015   going online with style - an intro to cssSpectrum 2015   going online with style - an intro to css
Spectrum 2015 going online with style - an intro to cssNeil Perlin
 
9- Learn CSS Fundamentals / Pseudo-classes
9- Learn CSS Fundamentals / Pseudo-classes9- Learn CSS Fundamentals / Pseudo-classes
9- Learn CSS Fundamentals / Pseudo-classesIn a Rocket
 
Advanced Technology for Web Application Design
Advanced Technology for Web Application DesignAdvanced Technology for Web Application Design
Advanced Technology for Web Application DesignBryce Kerley
 
Advanced sass/compass
Advanced sass/compassAdvanced sass/compass
Advanced sass/compassNick Cooley
 
CSS 開發加速指南-Sass & Compass
CSS 開發加速指南-Sass & CompassCSS 開發加速指南-Sass & Compass
CSS 開發加速指南-Sass & CompassLucien Lee
 
Css3 and gwt in perfect harmony
Css3 and gwt in perfect harmonyCss3 and gwt in perfect harmony
Css3 and gwt in perfect harmonyjdramaix
 
Css3 and gwt in perfect harmony
Css3 and gwt in perfect harmonyCss3 and gwt in perfect harmony
Css3 and gwt in perfect harmonyArcbees
 
CSS pattern libraries
CSS pattern librariesCSS pattern libraries
CSS pattern librariesRuss Weakley
 
CSharp presentation and software developement
CSharp presentation and software developementCSharp presentation and software developement
CSharp presentation and software developementfrwebhelp
 
Css3 transitions and animations + graceful degradation with jQuery
Css3 transitions and animations + graceful degradation with jQueryCss3 transitions and animations + graceful degradation with jQuery
Css3 transitions and animations + graceful degradation with jQueryAndrea Verlicchi
 
Doing More With Less
Doing More With LessDoing More With Less
Doing More With LessDavid Engel
 

Similar to The Cascade, Grids, Headings, and Selectors from an OOCSS Perspective, Ajax Experience 2009 (20)

What is Object Oriented CSS?
What is Object Oriented CSS?What is Object Oriented CSS?
What is Object Oriented CSS?
 
Display Suite: A Themers Perspective
Display Suite: A Themers PerspectiveDisplay Suite: A Themers Perspective
Display Suite: A Themers Perspective
 
Scalable CSS You and Your Back-End Coders Can Love - @CSSConf Asia 2014
Scalable CSS You and Your Back-End Coders Can Love - @CSSConf Asia 2014Scalable CSS You and Your Back-End Coders Can Love - @CSSConf Asia 2014
Scalable CSS You and Your Back-End Coders Can Love - @CSSConf Asia 2014
 
Dominate The Theme Layer
Dominate The Theme LayerDominate The Theme Layer
Dominate The Theme Layer
 
The Future State of Layout
The Future State of LayoutThe Future State of Layout
The Future State of Layout
 
Sass Essentials at Mobile Camp LA
Sass Essentials at Mobile Camp LASass Essentials at Mobile Camp LA
Sass Essentials at Mobile Camp LA
 
Building a Custom Theme in Drupal 8
Building a Custom Theme in Drupal 8Building a Custom Theme in Drupal 8
Building a Custom Theme in Drupal 8
 
Spectrum 2015 going online with style - an intro to css
Spectrum 2015   going online with style - an intro to cssSpectrum 2015   going online with style - an intro to css
Spectrum 2015 going online with style - an intro to css
 
9- Learn CSS Fundamentals / Pseudo-classes
9- Learn CSS Fundamentals / Pseudo-classes9- Learn CSS Fundamentals / Pseudo-classes
9- Learn CSS Fundamentals / Pseudo-classes
 
Advanced Technology for Web Application Design
Advanced Technology for Web Application DesignAdvanced Technology for Web Application Design
Advanced Technology for Web Application Design
 
Advanced sass/compass
Advanced sass/compassAdvanced sass/compass
Advanced sass/compass
 
CSS 開發加速指南-Sass & Compass
CSS 開發加速指南-Sass & CompassCSS 開發加速指南-Sass & Compass
CSS 開發加速指南-Sass & Compass
 
Css3 and gwt in perfect harmony
Css3 and gwt in perfect harmonyCss3 and gwt in perfect harmony
Css3 and gwt in perfect harmony
 
Css3 and gwt in perfect harmony
Css3 and gwt in perfect harmonyCss3 and gwt in perfect harmony
Css3 and gwt in perfect harmony
 
CSS pattern libraries
CSS pattern librariesCSS pattern libraries
CSS pattern libraries
 
CSharp presentation and software developement
CSharp presentation and software developementCSharp presentation and software developement
CSharp presentation and software developement
 
Css3 transitions and animations + graceful degradation with jQuery
Css3 transitions and animations + graceful degradation with jQueryCss3 transitions and animations + graceful degradation with jQuery
Css3 transitions and animations + graceful degradation with jQuery
 
Pfnp slides
Pfnp slidesPfnp slides
Pfnp slides
 
Web Typography
Web TypographyWeb Typography
Web Typography
 
Doing More With Less
Doing More With LessDoing More With Less
Doing More With Less
 

More from Nicole Sullivan

More from Nicole Sullivan (9)

Why are you here?
Why are you here?Why are you here?
Why are you here?
 
Don't feed the trolls
Don't feed the trollsDon't feed the trolls
Don't feed the trolls
 
CSS Power Tools
CSS Power ToolsCSS Power Tools
CSS Power Tools
 
Our Best Practices Are Killing Us
Our Best Practices Are Killing UsOur Best Practices Are Killing Us
Our Best Practices Are Killing Us
 
5 Mistakes of Massive CSS
5 Mistakes of Massive CSS5 Mistakes of Massive CSS
5 Mistakes of Massive CSS
 
Pourquoi la performance?
Pourquoi la performance?Pourquoi la performance?
Pourquoi la performance?
 
Design Fast Websites
Design Fast WebsitesDesign Fast Websites
Design Fast Websites
 
7 Habits of Exceptional Performance
7 Habits of Exceptional Performance7 Habits of Exceptional Performance
7 Habits of Exceptional Performance
 
After YSlow "A"
After YSlow "A"After YSlow "A"
After YSlow "A"
 

Recently uploaded

Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteDianaGray10
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfLoriGlavin3
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersRaghuram Pandurangan
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxLoriGlavin3
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxLoriGlavin3
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxLoriGlavin3
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
unit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxunit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxBkGupta21
 

Recently uploaded (20)

Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test Suite
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdf
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information Developers
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptx
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
unit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxunit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptx
 

The Cascade, Grids, Headings, and Selectors from an OOCSS Perspective, Ajax Experience 2009

  • 1. OBJECT-ORIENTED CSS scale to millions of users or thousands of pages
  • 2. NICOLE SULLIVAN “stubbornella” on the web
  • 5. THE “C” IN CSS understanding the cascade
  • 6. BROWSER DEFAULT STYLES ❖ Browsers have internal default stylesheets ❖ They are all different ❖ Use reset.css from YUI to level the playing field
  • 7. CLASS ORDER <p class=”message error”>Borken!</p> The order of the classes makes no difference.
  • 8. ORDER OF THE PROPERTY VALUE PAIRS .foo{color: red; color: blue;}
  • 9. BROWSER IGNORES BITS IT DOESN’T UNDERSTAND .foo{color: red; colour: blue;}
  • 10. ORDER OF THE RULESETS .foo{color: red;} .foo{color: blue;}
  • 11. ORDER OF THE STYLESHEETS <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http:// www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html> <head> <link rel="stylesheet" type="text/css" href="styles.css" /> <link rel="stylesheet" type="text/css" href="moreStyles.css" /> </head> <body> <p>My page</p> </body> </html>
  • 12. SPECIFICITY? Sort of like a game of poker
  • 13. FROM THE SPEC: ❖ Count 1 if the declaration is from is a 'style' attribute rather than a rule with a selector, 0 otherwise (= a) (In HTML, values of an element's "style" attribute are style sheet rules. These rules have no selectors, so a=1, b=0, c=0, and d=0.) ❖ Count the number of ID attributes in the selector (= b) ❖ Count the number of other attributes and pseudo-classes in the selector (= c) ❖ Count the number of element names and pseudo-elements in the selector (= d)
  • 14. IT GOES ON... ❖ The specificity is based only on the form of the selector. In particular, a selector of the form "[id=p33]" is counted as an attribute selector (a=0, b=0, c=1, d=0), even if the id attribute is defined as an "ID" in the source document's DTD. ❖ Concatenating the four numbers a-b-c-d (in a number system with a large base) gives the specificity.
  • 15. ROUGHLY SPEAKING... We need to calculate specificity faster...
  • 16. ID AND CLASS #nav p{color: red } .nav p{color: blue }
  • 17. INLINE STYLES <p style=”color: green;”>My page</p>
  • 18. !IMPORTANT p{color: red !important} <p style=”color: green;”>My page</p>
  • 19. CSS INHERITANCE body{font-size: 18px;} <body> <p>This text is 18px.</p> </body> http://www.w3.org/TR/CSS2/propidx.html
  • 20. AGGREGATION OF RULES <p class=”message error”>Boo</p> <p class=”message hint”>Boo</p> <p class=”message help”>Boo</p>
  • 21. POWERFUL misunderstanding of CSS has led to a mess...
  • 22.
  • 23.
  • 24.
  • 25.
  • 26.
  • 27.
  • 28. CODE IS TOO FRAGILE. Even the cleanest code gets ruined by the first non-expert to touch it.
  • 29. REQUIRE EXPERT ABILITY JUST TO GET STARTED. this is not a sign of maturity.
  • 30. CODE RE-USE IS ALMOST NONEXISTENT people don’t trust other developers’ code.
  • 31. FILE SIZE JUST KEEPS GETTING BIGGER As the site evolves we continuously modify the CSS.
  • 32. WHAT IS THE MOST IMPORTANT MISTAKE TALENTED CODERS ARE MAKING? Writing really clever modules.
  • 33. THE SIZE OF THEIR CSS WILL INCREASE in a 1:1 relationship with the number of blocks, pages, and complexity of content.
  • 34. WHAT IS OBJECT-ORIENTED CSS? A philosophy? A framework? A tool?
  • 35. MORE LIKE AN EVOLUTION OF THE LANGUAGE it makes CSS more powerful
  • 36. HOW IS IT DIFFERENT? ul{...} ul li{...} ul li a{...}
  • 37. HOW IS IT DIFFERENT? ul{...} ul li{...} ul li a{...} Until now, we focused all our effort here
  • 38. HOW IS IT DIFFERENT? ul{...} ul li{...} ul li a{...} But, the architecture lives here
  • 39. TERMINOLOGY CAN BE CONFUSING so forget about a 1:1 mapping with either CSS or OOP
  • 40. ALL OF THE CODE IS OPEN SOURCE: ON GITHUB http://wiki.github.com/stubbornella/oocss/
  • 41. selector heading module grid
  • 42. selector heading template grid
  • 44. Heading Level 1 Heading Level 2 HEADINGS Heading Level 3 Getting the look and feel you want with the semantics you Heading Level 4 need. Heading Level 5 Heading Level 6
  • 45.
  • 46.
  • 47.
  • 48.
  • 49. REUSING ELEMENTS MAKES THEM performance “freebies”
  • 50. COMPONENTS ARE LIKE LEGO Mix and match to create diverse and interesting pages.
  • 51. AVOID DUPLICATION Wasting performance resources on components that can’t add value.
  • 52. NEARLY IDENTICAL MODULES Headings 3 and 5 are too similar.
  • 53. Rule of thumb: If two modules look too similar to include on the same page, they are too similar to include together in a site, choose one!
  • 54. AVOID LOCATION- DEPENDENT STYLES Sandboxing is better than spaghetti, but leads to performance problems
  • 59. EVERY NOW AND THEN...
  • 62. IN CSS WE DO THIS ALL THE TIME
  • 64. A Heading should not become a Heading in another part of the page.
  • 65. AVOID EXAMPLE #weatherModule h3{color:red;} #tabs h3{color:blue} ❖ Global color undefined for h3, so it will be ‣ unstyled in new modules, ‣ developers forced to write more CSS for the same style
  • 66. AVOID EXAMPLE h3{color:black;} #weatherModule h3{color:red;} #tabs h3{color:blue} ❖ Global color defined (better!) ❖ Weather and tabs override default h3 ‣ three styles for h3 cannot co-exist in the same module ‣ default style cannot be used in weather and tabs without costly overrides ❖ Weather and tabs h3 can never be used outside of those modules
  • 67. CONSISTENCY Writing more rules to overwrite the crazy rules from before. e.g. Heading should behave predictably in any module.
  • 68. TRY THIS INSTEAD h1, .h1{...} h2, .h2{...} h3, .h3{...} h4, .h4{...} h5, .h5{...} h6, .h6{...} ❖ Global values defined ❖ Semantics respected (while allowing visual flexibility) <h3 class=”h6”>Heading</h3>
  • 69. NEED MORE THAN 6 HEADINGS? Really? Any duplicates? Any too similar?
  • 70. STILL NEED MORE HEADINGS? .category{...} .section{...} .product{...} .prediction{...} ❖ Extend the heading object via a class on the object itself ❖ Avoid using the cascade to change display of nested objects
  • 71. selector heading template grid
  • 72. TEMPLATE & GRIDS Be flexible - extensible height and width
  • 73. TEMPLATE • 807 bytes • 13 lines of code • easily extended to custom page and column width
  • 74. GRIDS • 574 bytes • 14 lines of code • Percentage widths adapt to different page sizes • Includes halfs, thirds, fourths, and fifths • No gutters • Infinite nesting and stacking
  • 77. FIXED DIMENSIONS limit the ways in which a module can be reused
  • 78. selector heading template grid
  • 79. TAMING SELECTORS sanity for our stylesheets
  • 80. SIZE OF THE CSS FILE AND IMPLIED HTTP REQUESTS are the biggest factor for CSS performance
  • 81. REFLOWS AND RENDERING TIME are (much!) less important
  • 82. DUPLICATION IS WORSE THAN STALE RULES because we have tools to deal with the latter
  • 83. DEFINE DEFAULT VALUES Don’t repeat this code in every object
  • 84. #weatherModule h3{color:red;} #tabs h3{color:blue} DEFINE DEFAULT VALUES Don’t repeat this code in every object
  • 85. X #weatherModule h3{color:red;} #tabs h3{color:blue} DEFINE DEFAULT VALUES Don’t repeat this code in every object
  • 86. X #weatherModule h3{color:red;} #tabs h3{color:blue} DEFINE DEFAULT VALUES Don’t repeat this code in every object h1, .h1{...} h2, .h2{...} h3, .h3{...} h4, .h4{...} h5, .h5{...} h6, .h6{...}
  • 87. DEFINE STRUCTURE IN A SEPARATE CLASS Don’t repeat this code in every object block inner hd bd ft
  • 88. div.error{...} STYLE CLASSES rather than elements
  • 89. X div.error{...} STYLE CLASSES rather than elements .error{ most of the code goes here }
  • 90. X div.error{...} STYLE CLASSES rather than elements .error{ most of the code goes here } div.error{ } p.error{ exceptions only } em.error{ }
  • 91. div{...} ul{...} p{..} AVOID STYLING ELEMENTS unless defining defaults
  • 92. div{...} X ul{...} p{..} AVOID STYLING ELEMENTS unless defining defaults .error{...} .section{...} .products{...}
  • 93. html body .myModule div .hd{...} .myModule2 .hd {...} GIVE RULES THE SAME STRENGTH Use cascade order to overwrite previous rules
  • 94. X html body .myModule div .hd{...} .myModule2 .hd {...} GIVE RULES THE SAME STRENGTH Use cascade order to overwrite previous rules .myModule .hd{...} .myModule2 .hd{...}
  • 95. .mod .hd{...} .ie .mod .hd{...} .weatherMod .hd {...} USE HACKS SPARINGLY And don’t let them change your specificity
  • 96. .mod .hd{...} X .ie .mod .hd{...} .weatherMod .hd {...} USE HACKS SPARINGLY And don’t let them change your specificity .mod .hd{color: red; _zoom:1;} .weatherMod .hd{...}
  • 97. .sidebar ul{...} .header ul {...} AVOID SPECIFYING LOCATION Apply classes to the object you wish to change
  • 98. X .sidebar ul{...} .header ul {...} AVOID SPECIFYING LOCATION Apply classes to the object you wish to change .mainNav{...} .subNav {...}
  • 99. AVOID OVERLY SPECIFIC CLASSES they’re all semantic, but limiting
  • 100. AVOID OVERLY SPECIFIC CLASSES they’re all semantic, but limiting .vehicle{...} .motorcycle{...} .ducati{...} .ducatiMonster620{...} .nicolesDucatiMonster620{...}
  • 101. AVOID OVERLY SPECIFIC CLASSES they’re all semantic, but limiting .vehicle{...} .motorcycle{...} .ducati{...} X .ducatiMonster620{...} .nicolesDucatiMonster620{...}
  • 102. #myUniqueIdentifier{...} #myUniqueIdentifier2{...} AVOID SINGLETONS ids can only be used once in any given page Source: Chris Griego
  • 103. X #myUniqueIdentifier{...} #myUniqueIdentifier2{...} AVOID SINGLETONS ids can only be used once in any given page Source: Chris Griego
  • 104. Media Subheading Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. USE MIXINS to avoid repeating code Media Extended Subheading Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
  • 105. .inner{...} .weatherMod .inner{...} .tr{...} .weatherMod .tr{...} .bl{...} .weatherMod .bl{...} ENCAPSULATION don’t access sub-nodes of an object directly inner
  • 106. .inner{...} X .weatherMod .inner{...} .tr{...} .weatherMod .tr{...} .bl{...} .weatherMod .bl{...} ENCAPSULATION don’t access sub-nodes of an object directly inner
  • 107. OOCSS: A REAL LIFE EXAMPLE Gonzalo Cordero Front-End Engineer @Yahoo! inc.
  • 108. Who
  • 109. Who
  • 110. Who
  • 111. Who
  • 116. DESIGN CONSIDERATIONS ❖ Cross browser compatible
  • 117. DESIGN CONSIDERATIONS ❖ Cross browser compatible ❖ Multi-language support
  • 118. DESIGN CONSIDERATIONS ❖ Cross browser compatible ❖ Multi-language support ❖ Accessible
  • 119. DESIGN CONSIDERATIONS ❖ Cross browser compatible ❖ Multi-language support ❖ Accessible ❖ Aggressive deadline to complete both layout and functionality
  • 124. RESULT
  • 126. WEB COMPROMISES ❖ Why does the “easy” turn so complicated?
  • 127. WEB COMPROMISES ❖ Why does the “easy” turn so complicated? ❖ Why do we need to compromise?
  • 128. WEB COMPROMISES ❖ Why does the “easy” turn so complicated? ❖ Why do we need to compromise? ❖ Why can’t we rely on a set of solid rules and structures? Like other platforms do?
  • 130. OOCSS SAVES THE DAY ❖ Single simple markup structure
  • 131. OOCSS SAVES THE DAY ❖ Single simple markup structure ❖ Cross browser support (even IE 5.5!)
  • 132. OOCSS SAVES THE DAY ❖ Single simple markup structure ❖ Cross browser support (even IE 5.5!) ❖ Very minimum CSS
  • 133. OOCSS SAVES THE DAY ❖ Single simple markup structure ❖ Cross browser support (even IE 5.5!) ❖ Very minimum CSS ❖ Scalable, easy to apply to multiple designs
  • 141. Why can’t the web have great tools to build and design interfaces?
  • 142.
  • 143.
  • 144.
  • 145.
  • 147. CSSBUILDR ❖ If we said we could reuse the same structure over and over again, what’s stopping us from doing so? ❖ Different modules and page grids can be easily built. ❖ Plug and Play, Mix and Match.
  • 148. CSSBUILDR: TECH SPECS ❖ Create and modify module contours, backgrounds, font- colors, etc. ❖ In two to three clicks you get a plug-and-play ready module that works cross browser. ❖ Built on top YUI.
  • 149. THANK YOU DEMO TIME ❖ ygonzalocordero@me.com ❖ Twitter: goonieiam
  • 150. PHOTO CREDITS Bernese Mountain Dog in a Suitcase by Sig20171 Family Outing by Jimbob The fast and the furious Car Show by Rob Young Young man and woman taking pictures of each other by RalphBijker Motion Gears - team force by RalphBijker Weighing In by Smig44_uk
  • 151. PHOTO CREDITS • “South Carolina” by Army.Mil • “So Happy Together” by kalandrakas • “sometimes, a hug is all what we need” by kalandrakas • “Blueprint background” by Ricketts Fish • Spaghetti Monster • Food Photography - Spaghetti Tossed with Veg Oil • Spaghetti alla bolognese
  • 152. PHOTO CREDITS • “You Crack Me Up” by http://flickr.com/photos/nickwheeleroz/2474196275/in/photostream/ • “red lego” by http://flickr.com/photos/niznoz/5753993/ • “Pablo’s cubism period began at three” by http://flickr.com/photos/wwworks/2475349116/in/set-72157608035966422/ • “Kuwait water tower” by http://flickr.com/photos/asam/327911794/ • idigit_teddy: http://www.flickr.com/photos/design_inspiration/238542495/ • lucianvenutian: http://www.flickr.com/photos/lucianvenutian/1142630637/ • Gimli_36: http://www.flickr.com/photos/navillot/1878124531/ • NathanFromDeVryEET: http://www.flickr.com/photos/thatguyfromcchs08/2300190277/ • Stabilo Boss: http://flickr.com/photos/stabilo-boss/101793494/in/set-72057594060779001/ • Dead Man's Hand • Poker • Spaghetti & Meatballs
  • 153. LET’S KEEP TALKING... http://stubbornella.org nicole@stubbornella.org “stubbornella” on the web... twitter, dopplr, slideshare, everywhere... http://github.com/stubbornella/oocss/ http://groups.google.com/group/object-oriented-css

Editor's Notes

  1. Who am I? I am a front-end architecture consultant, working on w3c beta, facebook. My focus is building building scalable CSS. That might mean millions of visitors, thousands of pages, or any site like a blog where content creation goes on long after the look and feel has stabilized. Even Faster Websites, Layers Magazine, Smush it, Yslow.
  2. Speaking the same language... avoid lingo, focus on what matters to design
  3. Which of these will be applied in case of conflict? No idea, the order of the classes makes no difference.
  4. The color will be blue, no problem to declare things multiple times. The last property value pair will win
  5. Blue is ignored because the browser doesn&amp;#x2019;t understand the british spelling. Red will be applied.
  6. Foo will be blue, you can define the same thing as many times as you like, the last definition will win. Much like variables.
  7. If the same values are declared in both stylesheets, moreStyles.css will win because it comes after styles.
  8. The paragraph will be red. IDs win over classes.
  9. Inline styles win over external stylesheets and styles in the head
  10. Important wins over everything, including inline styles
  11. Certain properties are passed to child nodes. If you set a font size for example, child nodes will have the same size font unless they have a more specific rule applied.
  12. If you apply two classes to an element, it will have the property value pairs of both. The cascade resolves conflicts. This allows you to aggregate more abstract classes with more specific, so you don&amp;#x2019;t repeat code.
  13. Flawed implementations,
  14. Perfectly accessible or high performance website, and then the first newbie to touch it, ruins it. Our code should be robust enough that newbies can contribute while maintaining the standards we&amp;#x2019;ve set.
  15. couple years coding in the basement by yourself before you are remotely useful. Profession needs to accommodate entry level, mid level, and architect level developers. Frankly, I&amp;#x2019;m tired of writing rounded corner boxes. I&amp;#x2019;ve done it 1000 times already. What I want is a system that allows newbies to do that part so I can focus on the architect level challenges.
  16. And for good reason. Currently there is no consistency or predictability.
  17. New (different) html pages should be able to be built without modifying the CSS.
  18. CSS classes - some are like classes, others like properties, and some are objects Its about taking programming best practices and applying them to writing CSS.
  19. Encourage reuse
  20. If we build new HTML pages from a component library, new pages won&amp;#x2019;t require new css. So what goes into a component library. First up, content objects.
  21. Anything else that should be consistent site-wide.
  22. Consistency &amp; Semantics
  23. You might be asking &amp;#x201C;what are location dependent styles?&amp;#x201D;, lets look at a programming parallel.
  24. Designing site-wide legos first, then pages can help. (better for flexible section) YDN homepage module, trying to use it on a 2 column layout
  25. Not because you can&apos;t do it, anyone at this conf can position something to the left and something else to the right. Demo template and grids.
  26. .mod{defines what it means to be a module} skins become really simple
  27. .mod{defines what it means to be a module} skins become really simple
  28. .mod{defines what it means to be a module} skins become really simple
  29. .mod{defines what it means to be a module} skins become really simple
  30. avoid the specificity game
  31. avoid the specificity game
  32. Need hacks for browsers other than IE5.5, 6, 7? You are doing something wrong.
  33. Need hacks for browsers other than IE5.5, 6, 7? You are doing something wrong.
  34. YUI contributor Work for Yahoo Home Page CSS buildr contributor
  35. YUI contributor Work for Yahoo Home Page CSS buildr contributor
  36. YUI contributor Work for Yahoo Home Page CSS buildr contributor
  37. I was recently given the task of creating this module
  38. The challenges: Cross browser, limited amount of time, high quality markup, accessible and of course only with css.
  39. The challenges: Cross browser, limited amount of time, high quality markup, accessible and of course only with css.
  40. The challenges: Cross browser, limited amount of time, high quality markup, accessible and of course only with css.