SlideShare a Scribd company logo
1 of 27
Rock Solid
CSS Architecture
The Genesis of CSS.
In the beginning there was the <blink> tag.
And the W3C gods saw that this was bad and separated the presentation from the
content.
The content they called “HTML” and the presentation they called “CSS.”
And the web developers cried “Blessed are we, for now we have separation of concerns
and our code will be forever maintainable.”
And there was great rejoicing on the Interwebs.
A Bit of Actual CSS History
1986 Saw the introduction of Standard Generalized Markup
Language (SGML) which included style sheets.
1992 ViolaWWW, the browser/editor developed by Tim Berners-
Lee had style sheets that were hard-coded into the program
1994 - First Proposed in 1994 by by Håkon Wium Lie
1996 - first W3C CSS Recommendation (CSS1)
1998 - CSS2 Recommendation.
2003 First Working Draft Module of CSS3 Released
Aug 2007 Basic box model
Apr 2011 Multi-column Layout
Jun 2011 Color Module Level 3
Sep 2011 Selectors Level 3
Nov 2011 Template Layout Module
Jun 2012 Media Queries
Sep 2014 Backgrounds and Borders Module Level 3
Håkon Wium Lie - CTO Opera Software
The Cascade
User-agent declarations
User normal declarations
User important declarations
Author important declarations
Author normal declarations
!
!
How to Calculate Specificity
Selector Types
1. ID selectors (e.g., #example).
2. Class selectors (e.g., .example), attributes selectors (e.g., [type="radio"]) and pseudo-
classes (e.g., :hover)
0 , 0 , 0 , 0
1 point if
It’s Inline
1 point for
each ID
selector
1 point for
each class
selector
1 point for
each type
selector
Specificity Examples <li id=”catTwo” class=”cat-li” style=”color:red”>
<article id=”myArticle” class=”my-article”>
<h1 id=”myHeadline” class=”my-headline”>
Hello Kitty
</h1>
<ol>
<li id=”catOne” class=”cat”>Calico</li>
<li id=”catTwo” class=”cat cat-2”>Calico</li>
</ol>
</article>
li + li: {color: blue;}
.cat:nth-child(2){color: purple;}
#catTwo:{color: green;}
.my-article .my-headline ol .cat-2{color: green;}
#myArticle .my-headline ol .cat-2{color: yellow;}
1,0,0,0
0,0,0,2
0,0,2,0
0,1,0,0
0,0,3,1
0,1,2,1
Why We Need CSS Architecture
Rule
Sorting
Algorithm
Rule Set
This worksThis Doesn’t
The Holy Grail of CSS Architecture
Maintainability
Scalability
Testability
Reusability
Predictability
The Separation of Style from Content
When it launched in May 2003, it
contained only five designs.
In February 2005, The Zen of CSS
Design was published by CSS Zen
Garden creator Dave Shea and
web designer Molly Holzschlag.
The book is based on 36 designs
featured at the Zen Garden site.
CSS Zen Garden
Object Oriented CSS, OOCCS
Nicole Sullivan - First
Introduces OOCSS at Web
Directions North in 2008
https://github.com/stubbornella/oocss/wiki
Nicole Sullivan, contributor to many open source
project such as CSS-Lint, currently an
Engineering Manager at npm, Inc.
Separation of Structure from Skin
<div class=’widget’>
<input/>
<button>Click Me</button>
</div>
.widget{
height: 100px;
width: 100px;
border: solid 1px blue;
background-color: yellow;
}
input{
width: 90px;
border: solid 1px blue;
background-color: yellow;
}
button{
width: 30px;
border: solid 1px blue;
background-color: yellow;
}
.widget{
height: 100px;
width: 100px;
}
input{
width: 90px;
}
button{
width: 30px;
}
.skin {
border: solid 1px blue;
background-color: yellow;
}
<div class=’widget skin’>
<input class=’skin’/>
<button class=’skin’>Click Me</button>
</div>
Before
After
Separation of Content from Container
<header>
<h2>Lorem</h2>
</header>
<footer>
<h2>Ipsum</h2>
</footer>
header h2{
width: 200px;
height: 260px;
padding: 20px;
color: blue;
}
footer h2{
width: 200px;
height: 260px;
padding: 30px;
color: red;
}
.global-size{
width: 200px;
height: 260px;
}
.header-h2{
padding: 20px;
color: blue;
}
footer-h2{
padding: 30px;
color: red;
}
<header>
<h2 class=”header-h2 global-size”>Lorem</h2>
</header>
<footer>
<h2 class=”footer-h2 global-size”>Ipsum</h2>
</footer>
Before
After
Block-Element-Modifier, BEM
Introduced by Yandex, one of the largest internet
companies in Europe, operating Russia’s most popular
search engine.
BEM is a class naming convention that forces you to organize
your CSS into reusable chunks of single-responsibility.
BEM uses only class selectors for styling on id’s or tag names.
Class names have up to three parts separated by underscores.
block-name_element-name_modifier-name
Defining Terms
Block : A functionally independent page component that can be reused
Element : A composite part of a block that can't be used separately from it.
Modifier : An entity that defines the appearance, state, or behavior of a block or element.
Blocks can be nested inside of other blocks
Blocks do not control their positions. No padding, margin, or position styles
Blocks have semantic class names. i.e. “contact-form”
Elements are nested inside of blocks.
Elements have semantic class names that are composites of their block
class name. i.e. “contact-form_submit-button
Blocks can be nested inside of other blocks
Blocks do not control their positions. No padding, margin, or position styles
Modifier class name describe their appearance. i.e. “contact-form_submit-button-
error”
Some BEM Visuals
Blocks
Elements
Modifiers
A Quick BEM Example
<form class=”contact-form”>
<input type=”text” class=”contact-form_email_error” />
<textarea class=”contact-form_message”></textarea>
<input type=”submit”
class=”contact-form_submit”
value=”submit”/>
</form>
.contact-form {
border: solid 1px blue;
background: white;
Width: 20em;
}
.contact-form_email {
width: 90%;
margin: 1em auto;
border: solid 1px grey;
}
.contact-form_email_error {
width: 90%;
margin: 1em auto;
border: solid 1px red;
}
.contact-form_submit {
width: 90%;
margin: 1em auto;
border: solid 1px grey;
}
BLOCK
ELEMENTS
MODIFIER
Scalable and Modular Architecture for CSS, SMACSS
An architecture based on CSS categorization.
Jonathan Snook
1. Base
2. Layout
3. Module
4. State
5. Theme
Base
Base rules are the defaults. They are almost exclusively single element selectors
but it could include attribute selectors, pseudo-class selectors, child selectors or
sibling selectors. Essentially, a base style says that wherever this element is on
the page, it should look like this.
h1 { font-size: 2em;}
p { color: grey;
line-height: 1.6em;
font-family: helvetica, sans-serif;
}
input[type=”text”]{ border: solid 1px blue;}
…
Base rules are styled
using type selectors so
they have low specificity.
Layout Rules
Layout rules divide the page into sections. Layouts hold one or more modules together.
.layout-grid { … }
.layout-grid .row{ … }
.layout-grid .cell { … }
Style layout rules with classes
that start with “layout-” and
then the name of the layout.
Modules
These are the re-usable bits like sidebars, navigation, page-footers. The bulk of your CSS
goes here.
.module-search-widget{ … }
.module-search-widget button{ … }
.module-search-widget .search-field{ … }
Prefix your module class
names with “module-”
and the module name.
State
State classes represent changes in application state. Use state classes to show how
things look when things are collapsed, in an error state, or expanded.
.is-error{ color: red;}
.is-error input {border-color: red;}
State classes start with
the prefix “is-”
Theme
Theme rules are the overrides necessary to create different themes. They mostly control
color, fonts and and other non-layout rules. This part is optional if you don’t need themes.
/* in module-name.css */
.mod {
border: 1px solid;
}
/* in blue-theme.css */
.mod {
border-color: blue;
}
Atomic CSS
Atomic CSS can be characterized as the principles of Reductio ad absurdum applied to OOCSS.
Why stop at separating structure from skin? Let’s keep on seperating until every class has only one
property. That’s ACSS.
CSS is a plague of locus sent by Håkon Wium Lie to destroy
all that holy with web development.
If you agree with this statement then Atomic CSS is for you.
Goodbye Stylesheets, Hello “inline”
<p class=”large-para”>
.large-para {
line-height: 2em;
font-family: sans-serif;
font-size: 1.6em;
}
<p class=”ls-2 ff-sans fs-16”>
.lh-2 {line-height: 2em;}
.ff-sans {font-family: sans-serif;}
.fs-16{ font-size: 1.6em;}
Atomizer
<div class="foo Bd C(#0280ae) Ta(c)">
<p class="Op(0) foo:h>Op(1)">Lorem ipsum</p>
</div>
Atomizer is a tool for creating Atomic CSS. Generate an Atomic stylesheet dynamically from the
Atomic classes you're actually using in your project (no unused styles!), or predeclare styles in
configuration.
It’s All About How you Separate Your Concerns
Style Content
OOCS, Atomic
HTML
CSS
JS
BEM, SMACSS
HTML
CSS
JS
HTML
CSS
JS
HTML
CSS
JS
Who does this guy think he is?
John Need
Front End Code Monkey
Galen Healthcare
Twitter : @JohnNeed
GitHub : https://github.com/johnneed
CodePen : http://codepen.io/johnneed/
Linked In : https://www.linkedin.com/in/johnneed
Read about the origins of the <blink> tag here
www.montulli.org/theoriginofthe<blink>tag

More Related Content

Similar to Rock Solid CSS Architecture

The CSS Handbook
The CSS HandbookThe CSS Handbook
The CSS Handbookjackchenvlo
 
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
 
OOCSS, SMACSS or BEM?
OOCSS, SMACSS or BEM?OOCSS, SMACSS or BEM?
OOCSS, SMACSS or BEM?Michael Posso
 
CSS Methodology
CSS MethodologyCSS Methodology
CSS MethodologyZohar Arad
 
Organize Your Website With Advanced CSS Tricks
Organize Your Website With Advanced CSS TricksOrganize Your Website With Advanced CSS Tricks
Organize Your Website With Advanced CSS TricksAndolasoft Inc
 
Structuring your CSS for maintainability: rules and guile lines to write CSS
Structuring your CSS for maintainability: rules and guile lines to write CSSStructuring your CSS for maintainability: rules and guile lines to write CSS
Structuring your CSS for maintainability: rules and guile lines to write CSSSanjoy Kr. Paul
 
Girl Develop It Cincinnati: Intro to HTML/CSS Class 4
Girl Develop It Cincinnati: Intro to HTML/CSS Class 4Girl Develop It Cincinnati: Intro to HTML/CSS Class 4
Girl Develop It Cincinnati: Intro to HTML/CSS Class 4Erin M. Kidwell
 
Architecture for css
Architecture for cssArchitecture for css
Architecture for cssMohamed Amin
 
HTML and CSS Coding Standards
HTML and CSS Coding StandardsHTML and CSS Coding Standards
HTML and CSS Coding StandardsSaajan Maharjan
 
Upstate CSCI 450 WebDev Chapter 3
Upstate CSCI 450 WebDev Chapter 3Upstate CSCI 450 WebDev Chapter 3
Upstate CSCI 450 WebDev Chapter 3DanWooster1
 
The Future State of Layout
The Future State of LayoutThe Future State of Layout
The Future State of LayoutStephen Hay
 
Front end workflow Presentation at Coffee@DBG by Praveen Vijayan
Front end workflow Presentation at Coffee@DBG by Praveen VijayanFront end workflow Presentation at Coffee@DBG by Praveen Vijayan
Front end workflow Presentation at Coffee@DBG by Praveen VijayanDeepu S Nath
 

Similar to Rock Solid CSS Architecture (20)

The CSS Handbook
The CSS HandbookThe CSS Handbook
The CSS Handbook
 
Pfnp slides
Pfnp slidesPfnp slides
Pfnp slides
 
Introduction to css
Introduction to cssIntroduction to css
Introduction to css
 
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...
 
OOCSS, SMACSS or BEM?
OOCSS, SMACSS or BEM?OOCSS, SMACSS or BEM?
OOCSS, SMACSS or BEM?
 
CSS Methodology
CSS MethodologyCSS Methodology
CSS Methodology
 
Css and its future
Css and its futureCss and its future
Css and its future
 
The Cascade is Dead
The Cascade is DeadThe Cascade is Dead
The Cascade is Dead
 
HowTo_CSS
HowTo_CSSHowTo_CSS
HowTo_CSS
 
HowTo_CSS
HowTo_CSSHowTo_CSS
HowTo_CSS
 
Css Systems
Css SystemsCss Systems
Css Systems
 
Organize Your Website With Advanced CSS Tricks
Organize Your Website With Advanced CSS TricksOrganize Your Website With Advanced CSS Tricks
Organize Your Website With Advanced CSS Tricks
 
Structuring your CSS for maintainability: rules and guile lines to write CSS
Structuring your CSS for maintainability: rules and guile lines to write CSSStructuring your CSS for maintainability: rules and guile lines to write CSS
Structuring your CSS for maintainability: rules and guile lines to write CSS
 
Girl Develop It Cincinnati: Intro to HTML/CSS Class 4
Girl Develop It Cincinnati: Intro to HTML/CSS Class 4Girl Develop It Cincinnati: Intro to HTML/CSS Class 4
Girl Develop It Cincinnati: Intro to HTML/CSS Class 4
 
Architecture for css
Architecture for cssArchitecture for css
Architecture for css
 
HTML and CSS Coding Standards
HTML and CSS Coding StandardsHTML and CSS Coding Standards
HTML and CSS Coding Standards
 
Upstate CSCI 450 WebDev Chapter 3
Upstate CSCI 450 WebDev Chapter 3Upstate CSCI 450 WebDev Chapter 3
Upstate CSCI 450 WebDev Chapter 3
 
Evolution of CSS
Evolution of CSSEvolution of CSS
Evolution of CSS
 
The Future State of Layout
The Future State of LayoutThe Future State of Layout
The Future State of Layout
 
Front end workflow Presentation at Coffee@DBG by Praveen Vijayan
Front end workflow Presentation at Coffee@DBG by Praveen VijayanFront end workflow Presentation at Coffee@DBG by Praveen Vijayan
Front end workflow Presentation at Coffee@DBG by Praveen Vijayan
 

Recently uploaded

Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsArshad QA
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Modelsaagamshah0812
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVshikhaohhpro
 
How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsAndolasoft Inc
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerThousandEyes
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...ICS
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfkalichargn70th171
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providermohitmore19
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️Delhi Call girls
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...harshavardhanraghave
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...MyIntelliSource, Inc.
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...kellynguyen01
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxComplianceQuest1
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Steffen Staab
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...Health
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsAlberto González Trastoy
 
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AISyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AIABDERRAOUF MEHENNI
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...panagenda
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...MyIntelliSource, Inc.
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfkalichargn70th171
 

Recently uploaded (20)

Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Models
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
 
How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.js
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docx
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
 
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AISyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
 

Rock Solid CSS Architecture

  • 2. The Genesis of CSS. In the beginning there was the <blink> tag. And the W3C gods saw that this was bad and separated the presentation from the content. The content they called “HTML” and the presentation they called “CSS.” And the web developers cried “Blessed are we, for now we have separation of concerns and our code will be forever maintainable.” And there was great rejoicing on the Interwebs.
  • 3. A Bit of Actual CSS History 1986 Saw the introduction of Standard Generalized Markup Language (SGML) which included style sheets. 1992 ViolaWWW, the browser/editor developed by Tim Berners- Lee had style sheets that were hard-coded into the program 1994 - First Proposed in 1994 by by Håkon Wium Lie 1996 - first W3C CSS Recommendation (CSS1) 1998 - CSS2 Recommendation. 2003 First Working Draft Module of CSS3 Released Aug 2007 Basic box model Apr 2011 Multi-column Layout Jun 2011 Color Module Level 3 Sep 2011 Selectors Level 3 Nov 2011 Template Layout Module Jun 2012 Media Queries Sep 2014 Backgrounds and Borders Module Level 3 Håkon Wium Lie - CTO Opera Software
  • 4. The Cascade User-agent declarations User normal declarations User important declarations Author important declarations Author normal declarations ! !
  • 5. How to Calculate Specificity Selector Types 1. ID selectors (e.g., #example). 2. Class selectors (e.g., .example), attributes selectors (e.g., [type="radio"]) and pseudo- classes (e.g., :hover) 0 , 0 , 0 , 0 1 point if It’s Inline 1 point for each ID selector 1 point for each class selector 1 point for each type selector
  • 6. Specificity Examples <li id=”catTwo” class=”cat-li” style=”color:red”> <article id=”myArticle” class=”my-article”> <h1 id=”myHeadline” class=”my-headline”> Hello Kitty </h1> <ol> <li id=”catOne” class=”cat”>Calico</li> <li id=”catTwo” class=”cat cat-2”>Calico</li> </ol> </article> li + li: {color: blue;} .cat:nth-child(2){color: purple;} #catTwo:{color: green;} .my-article .my-headline ol .cat-2{color: green;} #myArticle .my-headline ol .cat-2{color: yellow;} 1,0,0,0 0,0,0,2 0,0,2,0 0,1,0,0 0,0,3,1 0,1,2,1
  • 7. Why We Need CSS Architecture Rule Sorting Algorithm Rule Set This worksThis Doesn’t
  • 8. The Holy Grail of CSS Architecture Maintainability Scalability Testability Reusability Predictability
  • 9. The Separation of Style from Content When it launched in May 2003, it contained only five designs. In February 2005, The Zen of CSS Design was published by CSS Zen Garden creator Dave Shea and web designer Molly Holzschlag. The book is based on 36 designs featured at the Zen Garden site. CSS Zen Garden
  • 10. Object Oriented CSS, OOCCS Nicole Sullivan - First Introduces OOCSS at Web Directions North in 2008 https://github.com/stubbornella/oocss/wiki Nicole Sullivan, contributor to many open source project such as CSS-Lint, currently an Engineering Manager at npm, Inc.
  • 11. Separation of Structure from Skin <div class=’widget’> <input/> <button>Click Me</button> </div> .widget{ height: 100px; width: 100px; border: solid 1px blue; background-color: yellow; } input{ width: 90px; border: solid 1px blue; background-color: yellow; } button{ width: 30px; border: solid 1px blue; background-color: yellow; } .widget{ height: 100px; width: 100px; } input{ width: 90px; } button{ width: 30px; } .skin { border: solid 1px blue; background-color: yellow; } <div class=’widget skin’> <input class=’skin’/> <button class=’skin’>Click Me</button> </div> Before After
  • 12. Separation of Content from Container <header> <h2>Lorem</h2> </header> <footer> <h2>Ipsum</h2> </footer> header h2{ width: 200px; height: 260px; padding: 20px; color: blue; } footer h2{ width: 200px; height: 260px; padding: 30px; color: red; } .global-size{ width: 200px; height: 260px; } .header-h2{ padding: 20px; color: blue; } footer-h2{ padding: 30px; color: red; } <header> <h2 class=”header-h2 global-size”>Lorem</h2> </header> <footer> <h2 class=”footer-h2 global-size”>Ipsum</h2> </footer> Before After
  • 13. Block-Element-Modifier, BEM Introduced by Yandex, one of the largest internet companies in Europe, operating Russia’s most popular search engine. BEM is a class naming convention that forces you to organize your CSS into reusable chunks of single-responsibility. BEM uses only class selectors for styling on id’s or tag names. Class names have up to three parts separated by underscores. block-name_element-name_modifier-name
  • 14. Defining Terms Block : A functionally independent page component that can be reused Element : A composite part of a block that can't be used separately from it. Modifier : An entity that defines the appearance, state, or behavior of a block or element. Blocks can be nested inside of other blocks Blocks do not control their positions. No padding, margin, or position styles Blocks have semantic class names. i.e. “contact-form” Elements are nested inside of blocks. Elements have semantic class names that are composites of their block class name. i.e. “contact-form_submit-button Blocks can be nested inside of other blocks Blocks do not control their positions. No padding, margin, or position styles Modifier class name describe their appearance. i.e. “contact-form_submit-button- error”
  • 16. A Quick BEM Example <form class=”contact-form”> <input type=”text” class=”contact-form_email_error” /> <textarea class=”contact-form_message”></textarea> <input type=”submit” class=”contact-form_submit” value=”submit”/> </form> .contact-form { border: solid 1px blue; background: white; Width: 20em; } .contact-form_email { width: 90%; margin: 1em auto; border: solid 1px grey; } .contact-form_email_error { width: 90%; margin: 1em auto; border: solid 1px red; } .contact-form_submit { width: 90%; margin: 1em auto; border: solid 1px grey; } BLOCK ELEMENTS MODIFIER
  • 17. Scalable and Modular Architecture for CSS, SMACSS An architecture based on CSS categorization. Jonathan Snook 1. Base 2. Layout 3. Module 4. State 5. Theme
  • 18. Base Base rules are the defaults. They are almost exclusively single element selectors but it could include attribute selectors, pseudo-class selectors, child selectors or sibling selectors. Essentially, a base style says that wherever this element is on the page, it should look like this. h1 { font-size: 2em;} p { color: grey; line-height: 1.6em; font-family: helvetica, sans-serif; } input[type=”text”]{ border: solid 1px blue;} … Base rules are styled using type selectors so they have low specificity.
  • 19. Layout Rules Layout rules divide the page into sections. Layouts hold one or more modules together. .layout-grid { … } .layout-grid .row{ … } .layout-grid .cell { … } Style layout rules with classes that start with “layout-” and then the name of the layout.
  • 20. Modules These are the re-usable bits like sidebars, navigation, page-footers. The bulk of your CSS goes here. .module-search-widget{ … } .module-search-widget button{ … } .module-search-widget .search-field{ … } Prefix your module class names with “module-” and the module name.
  • 21. State State classes represent changes in application state. Use state classes to show how things look when things are collapsed, in an error state, or expanded. .is-error{ color: red;} .is-error input {border-color: red;} State classes start with the prefix “is-”
  • 22. Theme Theme rules are the overrides necessary to create different themes. They mostly control color, fonts and and other non-layout rules. This part is optional if you don’t need themes. /* in module-name.css */ .mod { border: 1px solid; } /* in blue-theme.css */ .mod { border-color: blue; }
  • 23. Atomic CSS Atomic CSS can be characterized as the principles of Reductio ad absurdum applied to OOCSS. Why stop at separating structure from skin? Let’s keep on seperating until every class has only one property. That’s ACSS. CSS is a plague of locus sent by Håkon Wium Lie to destroy all that holy with web development. If you agree with this statement then Atomic CSS is for you.
  • 24. Goodbye Stylesheets, Hello “inline” <p class=”large-para”> .large-para { line-height: 2em; font-family: sans-serif; font-size: 1.6em; } <p class=”ls-2 ff-sans fs-16”> .lh-2 {line-height: 2em;} .ff-sans {font-family: sans-serif;} .fs-16{ font-size: 1.6em;}
  • 25. Atomizer <div class="foo Bd C(#0280ae) Ta(c)"> <p class="Op(0) foo:h>Op(1)">Lorem ipsum</p> </div> Atomizer is a tool for creating Atomic CSS. Generate an Atomic stylesheet dynamically from the Atomic classes you're actually using in your project (no unused styles!), or predeclare styles in configuration.
  • 26. It’s All About How you Separate Your Concerns Style Content OOCS, Atomic HTML CSS JS BEM, SMACSS HTML CSS JS HTML CSS JS HTML CSS JS
  • 27. Who does this guy think he is? John Need Front End Code Monkey Galen Healthcare Twitter : @JohnNeed GitHub : https://github.com/johnneed CodePen : http://codepen.io/johnneed/ Linked In : https://www.linkedin.com/in/johnneed Read about the origins of the <blink> tag here www.montulli.org/theoriginofthe<blink>tag

Editor's Notes

  1. Jhkgkhgjkhgkhgkh jghkjghkj jhjhgjkhg
  2. sdf