SlideShare uma empresa Scribd logo
1 de 41
Baixar para ler offline
OOCSS, SMACSS or BEM?
@micposso
Michael Posso
Front-End developer @babbel NYC
Email Marketing
MeetUp Organizer
@micposso
Tables base structure
Lots of #ID selectors
Separate Structure from Styles
Animated GIFs
No semantics
Adobe FLASH!!!!
Old School “Web Design”
(DRY)
Don’t repeat yourself
(SEMANTICS)
Semantics is the study of the meaning of
linguistic expressions
(Object Oriented)
A system to be modeled as a set of objects that can be
controlled and manipulated in a modular manner
< Inheritance, can be extended and reusable >
(CSS Specificity)
Every selector has its place in the specificity hierarchy
smashingmagazine.com/2007/07/css-specificity-things-you-should-know/
(Comment you code)
Help your fellow coders
Samples of CSS comment styles
/* ====== media ====== */
/* _header styles */
/*
* — Section Heading —
*/
/**
* High level descriptions or summaries
*/
http://cssguidelin.es/#commenting
Semantics in HTML5 and CSS
HTML5 introduced a new elements that can improve semantics of
your code. With this semantic elements and semantic naming in your
CSS classes, they can complement each other.
<nav class=”primary”>
</nav>
<section class=”main”>
</section>
<aside class=”sidebar”>
</aside>
How to apply semantics in a global team
Global teams deal with a variety of cultures and linguistics differences
that can make semantics hard to apply.
Guidelines document
Use Interfaces
Delegate a reviewer
CSS Resets, which one you use?
“The reset styles given here are intentionally very generic. I don’t
particularly recommend that you just use this in its unaltered state in
your own projects. It should be tweaked, edited, extended, and
otherwise tuned to match your specific reset baseline”.
Eric Meyer
Eric Myer’s Reset
HTML5 Doctor
Your own?
(OOCSS)
Object Oriented CSS
OOCSS
Nicolle Sullivan 2009
github.com/stubbornella/oocss/wiki
slideshare.net/stubbornella/object-oriented-css
OOCSS Principles
Separate Structure and Skin
LAYOUT VS STYLES
Separate Container from Content
CONTAINER is not affected by its CONTENT
Object Oriented CSS Best Practices
Classes instead of IDs for styling
No multi-level descendant class specificity unless needed
Define your design in “Components”
Extend elements with targeted classes rather than parent classes
Mix and Match components
Organize your stylesheet into sections
Consider adding a table of contents
Camel case your class names - naming is oriented around the “object”
Basic Structure
Reset
GRID
Text styles
-headings
-content
Content Styles
-top level styles
-component specific
Identify Common Properties
.button1 {border-radius, height, color, font style, line-height, padding}
.button2 {border-radius, height, color, font style, line-height, padding}
.button3 {border-radius, height, color, font style, line-height, padding}
<div class=”button1”>Buy Now</div>
<div class=”button2”>More Information</div>
<div class=”button3”>Go Back</div>
OOCSS Way
.button-skin {border-radius, height, padding}
.cta {color, background-color}
.attention {color, background-color}
.enable {color, background-color}
<div class=”button-skin cta”>Buy Now</div>
<div class=”button-skin attention”>More Information</div>
<div class=”button-skin enable”>Go Back</div>
The Media Object Example
<div class="media">
<a href="http://twitter.com/stubbornella" class="img">
<img src="img.jpg" alt="Stubbornella" />
</a>
<div class="bd">
<p>@Stubbornella</p>
</div>
</div>
https://github.com/stubbornella/oocss/wiki/Content
The Media Object Example
/* ====== media ====== */
.media {margin:10px;}
.media, .bd {overflow:hidden; _overflow:visible; zoom:1;}
.media .img {float:left; margin-right: 10px;}
.media .img img{display:block;}
.media .imgExt{float:right; margin-left: 10px;}
https://github.com/stubbornella/oocss/wiki/Content
The Media Object Example (html + css)
Tradeoffs
Bloating of the HTML
More CSS rules
Have to update HTML to make changes
Benefits
Maintainable and organized*
Easy to implement, no tools necessary
DRY CSS
Good for big and small projects
(SMACSS)
Scalable Modular Architecture for CSS
SMACSS
Developed by Jonathan Snook
@snookca
https://snook.ca/
https://smacss.com/
Categorizing CSS Rules
1. Base
2. Layout
3. Module
4. State
5. Theme - Optional
File Architecture with Plain CSS
index.css - This is what will be linked in the HTML head. It uses
@import to bring the rest of the files into the document
base.css - reset, IDs and Element selectors OK
layout.css
theme.css - optional
module.css - will import other files from the modules folder
Modules folder
-media.css
-text-box.css
Using Sass
index.scss
_base.scss
_layout.scss
_theme.scss - optional
_module.scss
_var.scss
_utils.scss
Modules folder
-media.scss
-text-box.scss
(Space Naming)
Use space naming with SMACSS
Space Naming for Classes
layout.css
.l-right {float: right;}
.l-left {float: left;}
.l-align-center {text-align: center;}
.l-align-left {text-align: left;}
.l-align-right {text-align: right;}
Space Naming for Classes
modules/cards.css
.card {}
.card--label {}
.card--meta {}
.card--meta {}
.card--copy {}
Tradeoffs
Complicated Structure
Requires precompiler *
Bloating HTML with classes
Benefits
Maintainable and organized*
Faster rendering by using OOCSS principles
DRY CSS
Great for big projects with cross-functional teams
(BEM)
Block - Element - Modifier
BEM
Developed by Yandex
en.bem.info
It provides a rather strict way to
arrange your CSS classes into
independent modules
BEM best practices
Everything is a class
Avoid nesting of any kind
Keep CSS specificity very flat and low
Descriptive names for classes
Avoid element selectors
CSS classes in BEM are called entities
(BEM)
BEM goal is to help developers better understand the
relationship between the HTML and CSS in a given project
BEM classes relationship
.btn = BLOCK
.btn__price = ELEMENT Is the class that depends on .btn to work
.btn--orange= MODIFIER Extend the .btn class
A representation of a web page structure in terms of blocks, elements,
and modifiers
BEM tree
Using BEM naming conventions
/* Block component */
.btn {}
/* Element that depends upon the block */
.btn__price {}
/* Modifier that changes the style of the block */
.btn--orange {} or .btn__price--orange
HTML with BEM classes
<a class="btn btn--big btn--orange" href="http://google.com">
<span class="btn__price">$9.99</span>
<span class="btn__text">Subscribe</span>
</a>
How about JavaScript?
If you are using ID to select DOM element withJavaScript, try to use a
semantic name that describes the behavior.
$("js_btn--fadein").click(function(){ $("#div1").fadeIn();});
jQuery
<button class=”btn__cta btn--orange” id=”js_btn--fadein”>
BUY NOW $9.99</button>
HTML
Tradeoffs
Bloating HTML with classes
Ugly, Ugly, Ugly
Long *&^#$ class names
Benefits
Maintainable and organized*
Relationships are defined in the naming conventions
Great for big and small projects with cross-functional teams

Mais conteúdo relacionado

Mais procurados

Mais procurados (20)

HTML5 Tutorial
HTML5 TutorialHTML5 Tutorial
HTML5 Tutorial
 
Introduction to HTML and CSS
Introduction to HTML and CSSIntroduction to HTML and CSS
Introduction to HTML and CSS
 
BEM it! Introduction to BEM methodology
BEM it! Introduction to BEM methodologyBEM it! Introduction to BEM methodology
BEM it! Introduction to BEM methodology
 
CSS Best practice
CSS Best practiceCSS Best practice
CSS Best practice
 
Html & Css presentation
Html  & Css presentation Html  & Css presentation
Html & Css presentation
 
Bootstrap Part - 1
Bootstrap Part - 1Bootstrap Part - 1
Bootstrap Part - 1
 
Bootstrap 5 whats new
Bootstrap 5   whats newBootstrap 5   whats new
Bootstrap 5 whats new
 
cascading style sheet ppt
cascading style sheet pptcascading style sheet ppt
cascading style sheet ppt
 
Css backgrounds
Css   backgroundsCss   backgrounds
Css backgrounds
 
CSS 語法教學
CSS 語法教學CSS 語法教學
CSS 語法教學
 
Introduction to html
Introduction to htmlIntroduction to html
Introduction to html
 
Css position
Css positionCss position
Css position
 
0x02-HTML.pdf
0x02-HTML.pdf0x02-HTML.pdf
0x02-HTML.pdf
 
CSS3 Media Queries And Creating Adaptive Layouts
CSS3 Media Queries And Creating Adaptive LayoutsCSS3 Media Queries And Creating Adaptive Layouts
CSS3 Media Queries And Creating Adaptive Layouts
 
CSS selectors
CSS selectorsCSS selectors
CSS selectors
 
Introduction to HTML and CSS
Introduction to HTML and CSSIntroduction to HTML and CSS
Introduction to HTML and CSS
 
Bootstrap PPT by Mukesh
Bootstrap PPT by MukeshBootstrap PPT by Mukesh
Bootstrap PPT by Mukesh
 
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)
 
CSS Flexbox (flexible box layout)
CSS Flexbox (flexible box layout)CSS Flexbox (flexible box layout)
CSS Flexbox (flexible box layout)
 
0X0D - Responsive
0X0D - Responsive0X0D - Responsive
0X0D - Responsive
 

Semelhante a OOCSS, SMACSS or BEM?

Rock Solid CSS Architecture
Rock Solid CSS ArchitectureRock Solid CSS Architecture
Rock Solid CSS ArchitectureJohn Need
 
Build a better UI component library with Styled System
Build a better UI component library with Styled SystemBuild a better UI component library with Styled System
Build a better UI component library with Styled SystemHsin-Hao Tang
 
Css training tutorial css3 &amp; css4 essentials
Css training tutorial css3 &amp; css4 essentialsCss training tutorial css3 &amp; css4 essentials
Css training tutorial css3 &amp; css4 essentialsQA TrainingHub
 
CSS Methodology
CSS MethodologyCSS Methodology
CSS MethodologyZohar Arad
 
HTML and CSS Coding Standards
HTML and CSS Coding StandardsHTML and CSS Coding Standards
HTML and CSS Coding StandardsSaajan Maharjan
 
The Future is Modular, Jonathan Snook
The Future is Modular, Jonathan SnookThe Future is Modular, Jonathan Snook
The Future is Modular, Jonathan SnookFuture Insights
 
SMACSS Your Sass Up
SMACSS Your Sass UpSMACSS Your Sass Up
SMACSS Your Sass UpMina Markham
 
DW_lesson2.ppt
DW_lesson2.pptDW_lesson2.ppt
DW_lesson2.pptPramenathA
 
Architecture for css
Architecture for cssArchitecture for css
Architecture for cssMohamed Amin
 
TIBCO General Interface - CSS Guide
TIBCO General Interface - CSS GuideTIBCO General Interface - CSS Guide
TIBCO General Interface - CSS GuideRohan Chandane
 

Semelhante a OOCSS, SMACSS or BEM? (20)

Css Systems
Css SystemsCss Systems
Css Systems
 
Rock Solid CSS Architecture
Rock Solid CSS ArchitectureRock Solid CSS Architecture
Rock Solid CSS Architecture
 
Build a better UI component library with Styled System
Build a better UI component library with Styled SystemBuild a better UI component library with Styled System
Build a better UI component library with Styled System
 
Pfnp slides
Pfnp slidesPfnp slides
Pfnp slides
 
Css training tutorial css3 &amp; css4 essentials
Css training tutorial css3 &amp; css4 essentialsCss training tutorial css3 &amp; css4 essentials
Css training tutorial css3 &amp; css4 essentials
 
An Introduction to CSS
An Introduction to CSSAn Introduction to CSS
An Introduction to CSS
 
CSS Methodology
CSS MethodologyCSS Methodology
CSS Methodology
 
CSS Overview
CSS OverviewCSS Overview
CSS Overview
 
CSS.pptx
CSS.pptxCSS.pptx
CSS.pptx
 
HTML and CSS Coding Standards
HTML and CSS Coding StandardsHTML and CSS Coding Standards
HTML and CSS Coding Standards
 
The Future is Modular, Jonathan Snook
The Future is Modular, Jonathan SnookThe Future is Modular, Jonathan Snook
The Future is Modular, Jonathan Snook
 
SMACSS Your Sass Up
SMACSS Your Sass UpSMACSS Your Sass Up
SMACSS Your Sass Up
 
DW_lesson2.ppt
DW_lesson2.pptDW_lesson2.ppt
DW_lesson2.ppt
 
DW_lesson2.ppt
DW_lesson2.pptDW_lesson2.ppt
DW_lesson2.ppt
 
DW_lesson2.ppt
DW_lesson2.pptDW_lesson2.ppt
DW_lesson2.ppt
 
DW_lesson2.ppt
DW_lesson2.pptDW_lesson2.ppt
DW_lesson2.ppt
 
DW_lesson2.ppt
DW_lesson2.pptDW_lesson2.ppt
DW_lesson2.ppt
 
Architecture for css
Architecture for cssArchitecture for css
Architecture for css
 
Introduction to css
Introduction to cssIntroduction to css
Introduction to css
 
TIBCO General Interface - CSS Guide
TIBCO General Interface - CSS GuideTIBCO General Interface - CSS Guide
TIBCO General Interface - CSS Guide
 

Mais de Michael Posso

Using XR Experiences on Your WordPress
Using XR Experiences on Your WordPress   Using XR Experiences on Your WordPress
Using XR Experiences on Your WordPress Michael Posso
 
AMP and the instant web - WebPerformance NYC MeetUp group
AMP and the instant web - WebPerformance NYC MeetUp groupAMP and the instant web - WebPerformance NYC MeetUp group
AMP and the instant web - WebPerformance NYC MeetUp groupMichael Posso
 
OOCSS, SMACSS or BEM, what is the question...
OOCSS, SMACSS or BEM, what is the question...OOCSS, SMACSS or BEM, what is the question...
OOCSS, SMACSS or BEM, what is the question...Michael Posso
 
Interactive Responsive Emails - Creative ways to innovate in email development
Interactive Responsive Emails - Creative ways to innovate in email developmentInteractive Responsive Emails - Creative ways to innovate in email development
Interactive Responsive Emails - Creative ways to innovate in email developmentMichael Posso
 
Data visualization with d3 may19
Data visualization with d3 may19Data visualization with d3 may19
Data visualization with d3 may19Michael Posso
 

Mais de Michael Posso (6)

Using XR Experiences on Your WordPress
Using XR Experiences on Your WordPress   Using XR Experiences on Your WordPress
Using XR Experiences on Your WordPress
 
AMP and the instant web - WebPerformance NYC MeetUp group
AMP and the instant web - WebPerformance NYC MeetUp groupAMP and the instant web - WebPerformance NYC MeetUp group
AMP and the instant web - WebPerformance NYC MeetUp group
 
Slides bootstrap-4
Slides bootstrap-4Slides bootstrap-4
Slides bootstrap-4
 
OOCSS, SMACSS or BEM, what is the question...
OOCSS, SMACSS or BEM, what is the question...OOCSS, SMACSS or BEM, what is the question...
OOCSS, SMACSS or BEM, what is the question...
 
Interactive Responsive Emails - Creative ways to innovate in email development
Interactive Responsive Emails - Creative ways to innovate in email developmentInteractive Responsive Emails - Creative ways to innovate in email development
Interactive Responsive Emails - Creative ways to innovate in email development
 
Data visualization with d3 may19
Data visualization with d3 may19Data visualization with d3 may19
Data visualization with d3 may19
 

Último

Introduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptxIntroduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptxupamatechverse
 
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...RajaP95
 
UNIT-III FMM. DIMENSIONAL ANALYSIS
UNIT-III FMM.        DIMENSIONAL ANALYSISUNIT-III FMM.        DIMENSIONAL ANALYSIS
UNIT-III FMM. DIMENSIONAL ANALYSISrknatarajan
 
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 
(TARA) Talegaon Dabhade Call Girls Just Call 7001035870 [ Cash on Delivery ] ...
(TARA) Talegaon Dabhade Call Girls Just Call 7001035870 [ Cash on Delivery ] ...(TARA) Talegaon Dabhade Call Girls Just Call 7001035870 [ Cash on Delivery ] ...
(TARA) Talegaon Dabhade Call Girls Just Call 7001035870 [ Cash on Delivery ] ...ranjana rawat
 
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCollege Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCall Girls in Nagpur High Profile
 
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Christo Ananth
 
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...Call Girls in Nagpur High Profile
 
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Dr.Costas Sachpazis
 
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130Suhani Kapoor
 
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxDecoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxJoão Esperancinha
 
SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )Tsuyoshi Horigome
 
Coefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxCoefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxAsutosh Ranjan
 
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSKurinjimalarL3
 
the ladakh protest in leh ladakh 2024 sonam wangchuk.pptx
the ladakh protest in leh ladakh 2024 sonam wangchuk.pptxthe ladakh protest in leh ladakh 2024 sonam wangchuk.pptx
the ladakh protest in leh ladakh 2024 sonam wangchuk.pptxhumanexperienceaaa
 
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINEMANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINESIVASHANKAR N
 
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVHARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVRajaP95
 
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escortsranjana rawat
 

Último (20)

Introduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptxIntroduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptx
 
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...
 
UNIT-III FMM. DIMENSIONAL ANALYSIS
UNIT-III FMM.        DIMENSIONAL ANALYSISUNIT-III FMM.        DIMENSIONAL ANALYSIS
UNIT-III FMM. DIMENSIONAL ANALYSIS
 
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
(TARA) Talegaon Dabhade Call Girls Just Call 7001035870 [ Cash on Delivery ] ...
(TARA) Talegaon Dabhade Call Girls Just Call 7001035870 [ Cash on Delivery ] ...(TARA) Talegaon Dabhade Call Girls Just Call 7001035870 [ Cash on Delivery ] ...
(TARA) Talegaon Dabhade Call Girls Just Call 7001035870 [ Cash on Delivery ] ...
 
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCollege Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
 
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
 
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
 
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
 
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
 
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxDecoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
 
SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )
 
Coefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxCoefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptx
 
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
 
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
 
the ladakh protest in leh ladakh 2024 sonam wangchuk.pptx
the ladakh protest in leh ladakh 2024 sonam wangchuk.pptxthe ladakh protest in leh ladakh 2024 sonam wangchuk.pptx
the ladakh protest in leh ladakh 2024 sonam wangchuk.pptx
 
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINEMANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
 
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVHARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
 
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
 

OOCSS, SMACSS or BEM?

  • 1. OOCSS, SMACSS or BEM? @micposso
  • 2. Michael Posso Front-End developer @babbel NYC Email Marketing MeetUp Organizer @micposso
  • 3. Tables base structure Lots of #ID selectors Separate Structure from Styles Animated GIFs No semantics Adobe FLASH!!!! Old School “Web Design”
  • 5. (SEMANTICS) Semantics is the study of the meaning of linguistic expressions
  • 6. (Object Oriented) A system to be modeled as a set of objects that can be controlled and manipulated in a modular manner < Inheritance, can be extended and reusable >
  • 7. (CSS Specificity) Every selector has its place in the specificity hierarchy smashingmagazine.com/2007/07/css-specificity-things-you-should-know/
  • 8. (Comment you code) Help your fellow coders
  • 9. Samples of CSS comment styles /* ====== media ====== */ /* _header styles */ /* * — Section Heading — */ /** * High level descriptions or summaries */ http://cssguidelin.es/#commenting
  • 10. Semantics in HTML5 and CSS HTML5 introduced a new elements that can improve semantics of your code. With this semantic elements and semantic naming in your CSS classes, they can complement each other. <nav class=”primary”> </nav> <section class=”main”> </section> <aside class=”sidebar”> </aside>
  • 11. How to apply semantics in a global team Global teams deal with a variety of cultures and linguistics differences that can make semantics hard to apply. Guidelines document Use Interfaces Delegate a reviewer
  • 12. CSS Resets, which one you use? “The reset styles given here are intentionally very generic. I don’t particularly recommend that you just use this in its unaltered state in your own projects. It should be tweaked, edited, extended, and otherwise tuned to match your specific reset baseline”. Eric Meyer Eric Myer’s Reset HTML5 Doctor Your own?
  • 15. OOCSS Principles Separate Structure and Skin LAYOUT VS STYLES Separate Container from Content CONTAINER is not affected by its CONTENT
  • 16. Object Oriented CSS Best Practices Classes instead of IDs for styling No multi-level descendant class specificity unless needed Define your design in “Components” Extend elements with targeted classes rather than parent classes Mix and Match components Organize your stylesheet into sections Consider adding a table of contents Camel case your class names - naming is oriented around the “object”
  • 17. Basic Structure Reset GRID Text styles -headings -content Content Styles -top level styles -component specific
  • 18. Identify Common Properties .button1 {border-radius, height, color, font style, line-height, padding} .button2 {border-radius, height, color, font style, line-height, padding} .button3 {border-radius, height, color, font style, line-height, padding} <div class=”button1”>Buy Now</div> <div class=”button2”>More Information</div> <div class=”button3”>Go Back</div>
  • 19. OOCSS Way .button-skin {border-radius, height, padding} .cta {color, background-color} .attention {color, background-color} .enable {color, background-color} <div class=”button-skin cta”>Buy Now</div> <div class=”button-skin attention”>More Information</div> <div class=”button-skin enable”>Go Back</div>
  • 20. The Media Object Example <div class="media"> <a href="http://twitter.com/stubbornella" class="img"> <img src="img.jpg" alt="Stubbornella" /> </a> <div class="bd"> <p>@Stubbornella</p> </div> </div> https://github.com/stubbornella/oocss/wiki/Content
  • 21. The Media Object Example /* ====== media ====== */ .media {margin:10px;} .media, .bd {overflow:hidden; _overflow:visible; zoom:1;} .media .img {float:left; margin-right: 10px;} .media .img img{display:block;} .media .imgExt{float:right; margin-left: 10px;} https://github.com/stubbornella/oocss/wiki/Content
  • 22. The Media Object Example (html + css)
  • 23. Tradeoffs Bloating of the HTML More CSS rules Have to update HTML to make changes Benefits Maintainable and organized* Easy to implement, no tools necessary DRY CSS Good for big and small projects
  • 25. SMACSS Developed by Jonathan Snook @snookca https://snook.ca/ https://smacss.com/
  • 26. Categorizing CSS Rules 1. Base 2. Layout 3. Module 4. State 5. Theme - Optional
  • 27. File Architecture with Plain CSS index.css - This is what will be linked in the HTML head. It uses @import to bring the rest of the files into the document base.css - reset, IDs and Element selectors OK layout.css theme.css - optional module.css - will import other files from the modules folder Modules folder -media.css -text-box.css
  • 28. Using Sass index.scss _base.scss _layout.scss _theme.scss - optional _module.scss _var.scss _utils.scss Modules folder -media.scss -text-box.scss
  • 29. (Space Naming) Use space naming with SMACSS
  • 30. Space Naming for Classes layout.css .l-right {float: right;} .l-left {float: left;} .l-align-center {text-align: center;} .l-align-left {text-align: left;} .l-align-right {text-align: right;}
  • 31. Space Naming for Classes modules/cards.css .card {} .card--label {} .card--meta {} .card--meta {} .card--copy {}
  • 32. Tradeoffs Complicated Structure Requires precompiler * Bloating HTML with classes Benefits Maintainable and organized* Faster rendering by using OOCSS principles DRY CSS Great for big projects with cross-functional teams
  • 33. (BEM) Block - Element - Modifier
  • 34. BEM Developed by Yandex en.bem.info It provides a rather strict way to arrange your CSS classes into independent modules
  • 35. BEM best practices Everything is a class Avoid nesting of any kind Keep CSS specificity very flat and low Descriptive names for classes Avoid element selectors CSS classes in BEM are called entities
  • 36. (BEM) BEM goal is to help developers better understand the relationship between the HTML and CSS in a given project
  • 37. BEM classes relationship .btn = BLOCK .btn__price = ELEMENT Is the class that depends on .btn to work .btn--orange= MODIFIER Extend the .btn class A representation of a web page structure in terms of blocks, elements, and modifiers BEM tree
  • 38. Using BEM naming conventions /* Block component */ .btn {} /* Element that depends upon the block */ .btn__price {} /* Modifier that changes the style of the block */ .btn--orange {} or .btn__price--orange
  • 39. HTML with BEM classes <a class="btn btn--big btn--orange" href="http://google.com"> <span class="btn__price">$9.99</span> <span class="btn__text">Subscribe</span> </a>
  • 40. How about JavaScript? If you are using ID to select DOM element withJavaScript, try to use a semantic name that describes the behavior. $("js_btn--fadein").click(function(){ $("#div1").fadeIn();}); jQuery <button class=”btn__cta btn--orange” id=”js_btn--fadein”> BUY NOW $9.99</button> HTML
  • 41. Tradeoffs Bloating HTML with classes Ugly, Ugly, Ugly Long *&^#$ class names Benefits Maintainable and organized* Relationships are defined in the naming conventions Great for big and small projects with cross-functional teams