SlideShare a Scribd company logo
TACTICAL
HTML & CSS
Shay Howe
@shayhowe
learn.shayhowe.com
MODULAR
HTML & CSS
WORKSHOP
@shayhoweModular HTML & CSS
Shay Howe
@shayhowe
learn.shayhowe.com
@shayhoweModular HTML & CSS
1. The Problem
2. Groundwork
3. Assembling Layout
4. Accommodating Content
5. Onward
OUR SCHEDULE
@shayhoweModular HTML & CSS
THE
PROBLEM
The Gust by Willem van de Velde the Younger
@shayhoweModular HTML & CSS
COMMON PROBLEMS
• Websites have difficulty scaling
• Code becomes brittle
• Files and code bases begin to swell
@shayhoweModular HTML & CSS
WHAT’S WRONG
• Best practices aren’t exactly best practices
• Standards need to evolve
@shayhoweModular HTML & CSS
BEST BAD PRACTICES
• Avoid extra elements
• Avoid classes
• Leverage type selectors
• Leverage descendent selectors
@shayhoweModular HTML & CSS
BEST BAD PRACTICES
Avoiding classes
section	
  ul#nav	
  li	
  {...}
section:nth-­‐child(2)	
  div:nth-­‐child(7)	
  >	
  a	
  {...}
Leveraging selectors
a.btn	
  {...}
#main	
  a.btn	
  {...}
#main	
  div.feature	
  a.btn	
  {...}
@shayhoweModular HTML & CSS
BEST BAD PRACTICES
Bad
#contact	
  li:nth-­‐child(1)	
  input,
#contact	
  li:nth-­‐child(2)	
  input	
  {
	
  	
  width:	
  160px;
}
#contact	
  li:nth-­‐child(3)	
  textarea	
  {
	
  	
  width:	
  280px;
}
@shayhoweModular HTML & CSS
BEST BAD PRACTICES
Good
.col-­‐1	
  {
	
  	
  width:	
  160px;
}
.col-­‐2	
  {
	
  	
  width:	
  280px;
}
@shayhoweModular HTML & CSS
SPECIFICITY?
• Specificity determines which styles are applied
• Each selector has a specificity weight
• High specificity beats low specificity
• Low specificity is key
@shayhoweModular HTML & CSS
MEASURING SPECIFICITY
Formula
• IDs, Classes/Pseudo-classes/Attributes, Elements
High Specificity (Bad)
#primary	
  #main	
  div.gallery	
  figure.media
IDs: 2, Classes: 2, Elements: 2 — Compiled: 2–2–2
Low Specificity (Good)
.gallery-­‐media
IDs: 0, Classes: 1, Elements: 0 — Compiled: 0–1–0
@shayhoweModular HTML & CSS
@shayhoweModular HTML & CSS
WATCH SPECIFICITY
• Be explicit
• Keep specificity low
• Never use IDs or !important
• Avoid nested selectors (#main	
  .spotlight	
  strong	
  span)
@shayhoweModular HTML & CSS
WATCH SPECIFICITY
Bad
#primary	
  #main	
  div.gallery	
  {
	
  	
  text-­‐transform:	
  uppercase;
}
#primary	
  #main	
  div.gallery	
  figure.media	
  {
	
  	
  background:	
  #ccc;
}
@shayhoweModular HTML & CSS
WATCH SPECIFICITY
Good
.gallery	
  {
	
  	
  text-­‐transform:	
  uppercase;
}
.gallery-­‐media	
  {
	
  	
  background:	
  #ccc;
}
Parade of the Black Sea Fleet by Ivan Aivazovsky
@shayhoweModular HTML & CSS
MAINTAINABILITY
Code must be...
• Organized
• Modular
• Performant
@shayhoweModular HTML & CSS
METHODOLOGIES
OOCSS
• Object-Oriented CSS
From Nicole Sullivan – oocss.org
SMACSS
• Scalable and Modular Architecture for CSS
From Jonathan Snook – smacss.com
@shayhoweModular HTML & CSS
GROUNDWORK
@shayhoweModular HTML & CSS
REUSE CODE
• Do not duplicate code
• Remove old code
• Defer loading subsequent styles
@shayhoweModular HTML & CSS
REUSE CODE
Bad
.news	
  {
	
  	
  background:	
  #eee;
	
  	
  color:	
  #666;
}
.social	
  {
	
  	
  background:	
  #eee;
	
  	
  color:	
  #666;
}
@shayhoweModular HTML & CSS
REUSE CODE
Good
.news,
.social	
  {
	
  	
  background:	
  #eee;
	
  	
  color:	
  #666;
}
Better
.feat-­‐box	
  {
	
  	
  background:	
  #eee;
	
  	
  color:	
  #666;
}
@shayhoweModular HTML & CSS
USE CLASSES
• Write understandable class names
• Avoid unnecessary nesting
• Use same strength specificity
@shayhoweModular HTML & CSS
USE CLASSES
Bad
.feat-­‐box	
  .callout	
  .pr	
  {
	
  	
  font-­‐size:	
  12px;
}
.feat-­‐box	
  .callout	
  .pr	
  .un	
  {
	
  	
  color:	
  #39f;
}
@shayhoweModular HTML & CSS
USE CLASSES
Good
.feat-­‐box	
  .price	
  {
	
  	
  font-­‐size:	
  12px;
}
.feat-­‐box	
  .unit	
  {
	
  	
  color:	
  #39f;
}
@shayhoweModular HTML & CSS
USE CLASSES
Bad
.btn.large	
  {
	
  	
  font-­‐size:	
  24px;	
  	
  
	
  	
  padding:	
  15px	
  30px;
}
<div	
  class="btn	
  large">...</div>
@shayhoweModular HTML & CSS
USE CLASSES
Good
.btn-­‐large	
  {
	
  	
  font-­‐size:	
  24px;
	
  	
  padding:	
  15px	
  30px;
}
<div	
  class="btn-­‐large">...</div>
@shayhoweModular HTML & CSS
ASSEMBLING
LAYOUT
@shayhoweModular HTML & CSS
ABSTRACT STRUCTURE
• Separate presentation (or theme) from layout
• Create an object layer for layout
• Create a skin layer for theme
• Use a grid
@shayhoweModular HTML & CSS
ABSTRACT STRUCTURE
Bad
.news	
  {
	
  	
  background:	
  #eee;
	
  	
  color:	
  #666;
	
  	
  margin:	
  0	
  10px;
	
  	
  width:	
  400px;
}
<div	
  class="news">...</div>
@shayhoweModular HTML & CSS
ABSTRACT STRUCTURE
Good
.grid-­‐4	
  {
	
  	
  margin:	
  0	
  10px;
	
  	
  width:	
  400px;
}
.feat-­‐box	
  {
	
  	
  background:	
  #eee;
	
  	
  color:	
  #666;
}
<div	
  class="grid-­‐4	
  feat-­‐box">...</div>
@shayhoweModular HTML & CSS
TRANSPARENTIZE ELEMENTS
• Stylize elements to be transparent
• Keep visual properties apart from layout
properties
@shayhoweModular HTML & CSS
TRANSPARENTIZE ELEMENTS
Bad
.pagination	
  {
	
  	
  border-­‐radius:	
  5px;
	
  	
  border:	
  1px	
  solid	
  #eee;
	
  	
  margin:	
  0	
  10px;
	
  	
  width:	
  620px;
}
<ul	
  class="pagination">...</ul>
@shayhoweModular HTML & CSS
TRANSPARENTIZE ELEMENTS
Good
.grid-­‐8	
  {
	
  	
  margin:	
  0	
  10px;
	
  	
  width:	
  620px;
}
.offset-­‐box	
  {
	
  	
  border-­‐radius:	
  5px;
	
  	
  border:	
  1px	
  solid	
  #eee;
}
<ul	
  class="grid-­‐8	
  offset-­‐box">...</ul>
@shayhoweModular HTML & CSS
CREATE ADAPTABLE LAYOUTS
• Height and width should be flexible
• Height should extend with content
• Width should extend with a grid
@shayhoweModular HTML & CSS
CREATE ADAPTABLE LAYOUTS
Bad
#main	
  {
	
  	
  float:	
  left;
	
  	
  margin:	
  0	
  10px;
	
  	
  width:	
  620px;
}
#aside	
  {
	
  	
  float:	
  left;
	
  	
  margin:	
  0	
  10px;
	
  	
  width:	
  300px;
}
@shayhoweModular HTML & CSS
CREATE ADAPTABLE LAYOUTS
Good
.grid-­‐4,
.grid-­‐8	
  {
	
  	
  float:	
  left;
	
  	
  margin:	
  0	
  10px;
}
.grid-­‐4	
  {
	
  	
  width:	
  300px;
}
.grid-­‐8	
  {
	
  	
  width:	
  620px;
}
@shayhoweModular HTML & CSS
ASSEMBLING LAYOUT
IN PRACTICE
http://bit.ly/modular-html-css
@shayhoweModular HTML & CSS
ACCOMMODATING
CONTENT
@shayhoweModular HTML & CSS
SEPARATE CONTENT
• Separate content from container
• Stylize content regardless of container
@shayhoweModular HTML & CSS
SEPARATE CONTENT
Bad
.alert	
  {
	
  	
  background:	
  #f2dede;
	
  	
  border-­‐radius:	
  10px;
	
  	
  color:	
  #b94a48;
	
  	
  padding:	
  10px	
  20px;
}
<div	
  class="alert">...</div>
@shayhoweModular HTML & CSS
SEPARATE CONTENT
Good
.alert	
  {
	
  	
  border-­‐radius:	
  10px;
	
  	
  padding:	
  10px	
  20px;
}
.alert-­‐error	
  {
	
  	
  background:	
  #f2dede;
	
  	
  color:	
  #b94a48;
}
<div	
  class="alert	
  alert-­‐error">...</div>
@shayhoweModular HTML & CSS
AVOID PARENT DEPENDENCY
• Remove parent container dependency
• Decouple CSS from HTML
• Create components to be used anywhere
@shayhoweModular HTML & CSS
AVOID PARENT DEPENDENCY
Bad
.feat-­‐box	
  {
	
  	
  background:	
  #eee;
}
article	
  .feat-­‐box	
  {
	
  	
  background:	
  #fff;
}
<article>
	
  	
  <div	
  class="feat-­‐box">...</div>
</article>
@shayhoweModular HTML & CSS
AVOID PARENT DEPENDENCY
Good
.feat-­‐box	
  {
	
  	
  background:	
  #eee;
}
.feat-­‐box-­‐alt	
  {
	
  	
  background:	
  #fff;
}
<article>
	
  	
  <div	
  class="feat-­‐box-­‐alt">...</div>
</article>
@shayhoweModular HTML & CSS
FAVOR SEMANTICS
• Allow elements to adapt
• Uses individual classes to extend modules
@shayhoweModular HTML & CSS
FAVOR SEMANTICS
Bad
.feat-­‐box	
  h2	
  {
	
  	
  color:	
  #f60;
	
  	
  font:	
  18px	
  Helvetica,	
  sans-­‐serif;
}
<div	
  class="feat-­‐box">
	
  	
  <h2>...</h2>
</div>
@shayhoweModular HTML & CSS
FAVOR SEMANTICS
Good
.feat-­‐subhead	
  {
	
  	
  color:	
  #f60;
	
  	
  font:	
  18px	
  Helvetica,	
  sans-­‐serif;
}
<div	
  class="feat-­‐box">
	
  	
  <h2	
  class="feat-­‐subhead">...</h2>
</div>
@shayhoweModular HTML & CSS
ACCOMMODATING CONTENT
IN PRACTICE
http://bit.ly/modular-html-css
@shayhoweModular HTML & CSS
ONWARD
Ships on the Roadstead by Willem van de Velde the Younger
@shayhoweModular HTML & CSS
APPROACH
• Stop thinking about pages
• Start thinking about components
• Take visual inventory
@shayhoweModular HTML & CSS
THEMES
• Decouple HTML and CSS
• Separate presentation from layout
• Separate content from container
• Extend elements with classes
@shayhoweModular HTML & CSS
OUTCOMES
• Maintainability!
• Reusable code, less duplication
• Flexibility and extensibility
• Improved standards
@shayhoweModular HTML & CSS
WHAT’S NEXT
Build a styleguide
• Twitter Bootstrap, Zurb Foundation
Review methodologies
• OOCSS, SMACSS
Test your code
• CSS Lint, Inspector, PageSpeed
@shayhoweModular HTML & CSS
THANK YOU!
Questions?
@shayhowe
http://learn.shayhowe.com
Ad

More Related Content

What's hot (20)

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
Josh Jeffryes
 
Code &amp; design your first website (3:16)
Code &amp; design your first website (3:16)Code &amp; design your first website (3:16)
Code &amp; design your first website (3:16)
Thinkful
 
Web 102 INtro to CSS
Web 102  INtro to CSSWeb 102  INtro to CSS
Web 102 INtro to CSS
Hawkman Academy
 
HTML5, just another presentation :)
HTML5, just another presentation :)HTML5, just another presentation :)
HTML5, just another presentation :)
François Massart
 
Prototyping w/HTML5 and CSS3
Prototyping w/HTML5 and CSS3Prototyping w/HTML5 and CSS3
Prototyping w/HTML5 and CSS3
Todd Zaki Warfel
 
Code & Design your first website 4/18
Code & Design your first website 4/18Code & Design your first website 4/18
Code & Design your first website 4/18
TJ Stalcup
 
Html5 public
Html5 publicHtml5 public
Html5 public
doodlemoonch
 
CSS Frameworks
CSS FrameworksCSS Frameworks
CSS Frameworks
Mike Crabb
 
Blog HTML example for IML 295
Blog HTML example for IML 295Blog HTML example for IML 295
Blog HTML example for IML 295
Evan Hughes
 
Cssbestpracticesjstyleguidejandtips 150830184202-lva1-app6892
Cssbestpracticesjstyleguidejandtips 150830184202-lva1-app6892Cssbestpracticesjstyleguidejandtips 150830184202-lva1-app6892
Cssbestpracticesjstyleguidejandtips 150830184202-lva1-app6892
Deepak Sharma
 
The Future Of CSS
The Future Of CSSThe Future Of CSS
The Future Of CSS
Andy Budd
 
CSS pattern libraries
CSS pattern librariesCSS pattern libraries
CSS pattern libraries
Russ Weakley
 
Advanced CSS Troubleshooting & Efficiency
Advanced CSS Troubleshooting & EfficiencyAdvanced CSS Troubleshooting & Efficiency
Advanced CSS Troubleshooting & Efficiency
Denise Jacobs
 
Html5 ux london
Html5 ux londonHtml5 ux london
Html5 ux london
Todd Zaki Warfel
 
Progressive Prototyping w/HTML5, CSS3 and jQuery
Progressive Prototyping w/HTML5, CSS3 and jQueryProgressive Prototyping w/HTML5, CSS3 and jQuery
Progressive Prototyping w/HTML5, CSS3 and jQuery
Todd Zaki Warfel
 
CSS - OOCSS, SMACSS and more
CSS - OOCSS, SMACSS and moreCSS - OOCSS, SMACSS and more
CSS - OOCSS, SMACSS and more
Russ Weakley
 
Introduction to HTML5
Introduction to HTML5Introduction to HTML5
Introduction to HTML5
Terry Ryan
 
Quality Development with CSS3
Quality Development with CSS3Quality Development with CSS3
Quality Development with CSS3
Shay Howe
 
Intro to CSS
Intro to CSSIntro to CSS
Intro to CSS
Randy Oest II
 
HTML/CSS Web Blog Example
HTML/CSS Web Blog ExampleHTML/CSS Web Blog Example
HTML/CSS Web Blog Example
Michael Bodie
 
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
Josh Jeffryes
 
Code &amp; design your first website (3:16)
Code &amp; design your first website (3:16)Code &amp; design your first website (3:16)
Code &amp; design your first website (3:16)
Thinkful
 
HTML5, just another presentation :)
HTML5, just another presentation :)HTML5, just another presentation :)
HTML5, just another presentation :)
François Massart
 
Prototyping w/HTML5 and CSS3
Prototyping w/HTML5 and CSS3Prototyping w/HTML5 and CSS3
Prototyping w/HTML5 and CSS3
Todd Zaki Warfel
 
Code & Design your first website 4/18
Code & Design your first website 4/18Code & Design your first website 4/18
Code & Design your first website 4/18
TJ Stalcup
 
CSS Frameworks
CSS FrameworksCSS Frameworks
CSS Frameworks
Mike Crabb
 
Blog HTML example for IML 295
Blog HTML example for IML 295Blog HTML example for IML 295
Blog HTML example for IML 295
Evan Hughes
 
Cssbestpracticesjstyleguidejandtips 150830184202-lva1-app6892
Cssbestpracticesjstyleguidejandtips 150830184202-lva1-app6892Cssbestpracticesjstyleguidejandtips 150830184202-lva1-app6892
Cssbestpracticesjstyleguidejandtips 150830184202-lva1-app6892
Deepak Sharma
 
The Future Of CSS
The Future Of CSSThe Future Of CSS
The Future Of CSS
Andy Budd
 
CSS pattern libraries
CSS pattern librariesCSS pattern libraries
CSS pattern libraries
Russ Weakley
 
Advanced CSS Troubleshooting & Efficiency
Advanced CSS Troubleshooting & EfficiencyAdvanced CSS Troubleshooting & Efficiency
Advanced CSS Troubleshooting & Efficiency
Denise Jacobs
 
Progressive Prototyping w/HTML5, CSS3 and jQuery
Progressive Prototyping w/HTML5, CSS3 and jQueryProgressive Prototyping w/HTML5, CSS3 and jQuery
Progressive Prototyping w/HTML5, CSS3 and jQuery
Todd Zaki Warfel
 
CSS - OOCSS, SMACSS and more
CSS - OOCSS, SMACSS and moreCSS - OOCSS, SMACSS and more
CSS - OOCSS, SMACSS and more
Russ Weakley
 
Introduction to HTML5
Introduction to HTML5Introduction to HTML5
Introduction to HTML5
Terry Ryan
 
Quality Development with CSS3
Quality Development with CSS3Quality Development with CSS3
Quality Development with CSS3
Shay Howe
 
HTML/CSS Web Blog Example
HTML/CSS Web Blog ExampleHTML/CSS Web Blog Example
HTML/CSS Web Blog Example
Michael Bodie
 

Similar to Modular HTML & CSS Workshop (20)

Modular HTML & CSS Turbo Workshop
Modular HTML & CSS Turbo WorkshopModular HTML & CSS Turbo Workshop
Modular HTML & CSS Turbo Workshop
Shay Howe
 
Object-Oriented CSS 從 OOCSS, SMACSS, BEM 到 AMCSS
Object-Oriented CSS 從 OOCSS, SMACSS, BEM 到 AMCSSObject-Oriented CSS 從 OOCSS, SMACSS, BEM 到 AMCSS
Object-Oriented CSS 從 OOCSS, SMACSS, BEM 到 AMCSS
Li-Wei Lu
 
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
Erin M. Kidwell
 
Web
WebWeb
Web
Sreejith Ramakrishnan
 
Class15
Class15Class15
Class15
Jiyeon Lee
 
HTML5 & CSS3 Flag
HTML5 & CSS3 FlagHTML5 & CSS3 Flag
HTML5 & CSS3 Flag
Christopher Schmitt
 
Highly Maintainable, Efficient, and Optimized CSS
Highly Maintainable, Efficient, and Optimized CSSHighly Maintainable, Efficient, and Optimized CSS
Highly Maintainable, Efficient, and Optimized CSS
Zoe Gillenwater
 
Source Ordered Templates - - Joomla!Days NL 2009 #jd09nl
Source Ordered Templates - - Joomla!Days NL 2009 #jd09nlSource Ordered Templates - - Joomla!Days NL 2009 #jd09nl
Source Ordered Templates - - Joomla!Days NL 2009 #jd09nl
Joomla!Days Netherlands
 
Css intro
Css introCss intro
Css intro
Julia Vi
 
The Future of CSS
The Future of CSSThe Future of CSS
The Future of CSS
elliando dias
 
Future-proof styling in Drupal (8)
Future-proof styling in Drupal (8)Future-proof styling in Drupal (8)
Future-proof styling in Drupal (8)
Hajas Tamás
 
Be nice to your designers
Be nice to your designersBe nice to your designers
Be nice to your designers
Pai-Cheng Tao
 
Implementing Awesome: An HTML5/CSS3 Workshop
Implementing Awesome: An HTML5/CSS3 WorkshopImplementing Awesome: An HTML5/CSS3 Workshop
Implementing Awesome: An HTML5/CSS3 Workshop
Shoshi Roberts
 
Fewd week2 slides
Fewd week2 slidesFewd week2 slides
Fewd week2 slides
William Myers
 
CSS workshop @ OutSystems
CSS workshop @ OutSystemsCSS workshop @ OutSystems
CSS workshop @ OutSystems
Ruben Goncalves
 
Pertemuan 7
Pertemuan 7Pertemuan 7
Pertemuan 7
beiharira
 
Css for Development
Css for DevelopmentCss for Development
Css for Development
tsengsite
 
HTML5 for ASP.NET Developers
HTML5 for ASP.NET DevelopersHTML5 for ASP.NET Developers
HTML5 for ASP.NET Developers
Justin Lee
 
Css week10 2019 2020 for g10 by eng.osama ghandour
Css week10 2019 2020 for g10 by eng.osama ghandourCss week10 2019 2020 for g10 by eng.osama ghandour
Css week10 2019 2020 for g10 by eng.osama ghandour
Osama Ghandour Geris
 
HTML5 y CSS3
HTML5 y CSS3HTML5 y CSS3
HTML5 y CSS3
InterGraphicDESIGNS
 
Modular HTML & CSS Turbo Workshop
Modular HTML & CSS Turbo WorkshopModular HTML & CSS Turbo Workshop
Modular HTML & CSS Turbo Workshop
Shay Howe
 
Object-Oriented CSS 從 OOCSS, SMACSS, BEM 到 AMCSS
Object-Oriented CSS 從 OOCSS, SMACSS, BEM 到 AMCSSObject-Oriented CSS 從 OOCSS, SMACSS, BEM 到 AMCSS
Object-Oriented CSS 從 OOCSS, SMACSS, BEM 到 AMCSS
Li-Wei Lu
 
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
Erin M. Kidwell
 
Highly Maintainable, Efficient, and Optimized CSS
Highly Maintainable, Efficient, and Optimized CSSHighly Maintainable, Efficient, and Optimized CSS
Highly Maintainable, Efficient, and Optimized CSS
Zoe Gillenwater
 
Source Ordered Templates - - Joomla!Days NL 2009 #jd09nl
Source Ordered Templates - - Joomla!Days NL 2009 #jd09nlSource Ordered Templates - - Joomla!Days NL 2009 #jd09nl
Source Ordered Templates - - Joomla!Days NL 2009 #jd09nl
Joomla!Days Netherlands
 
Future-proof styling in Drupal (8)
Future-proof styling in Drupal (8)Future-proof styling in Drupal (8)
Future-proof styling in Drupal (8)
Hajas Tamás
 
Be nice to your designers
Be nice to your designersBe nice to your designers
Be nice to your designers
Pai-Cheng Tao
 
Implementing Awesome: An HTML5/CSS3 Workshop
Implementing Awesome: An HTML5/CSS3 WorkshopImplementing Awesome: An HTML5/CSS3 Workshop
Implementing Awesome: An HTML5/CSS3 Workshop
Shoshi Roberts
 
CSS workshop @ OutSystems
CSS workshop @ OutSystemsCSS workshop @ OutSystems
CSS workshop @ OutSystems
Ruben Goncalves
 
Css for Development
Css for DevelopmentCss for Development
Css for Development
tsengsite
 
HTML5 for ASP.NET Developers
HTML5 for ASP.NET DevelopersHTML5 for ASP.NET Developers
HTML5 for ASP.NET Developers
Justin Lee
 
Css week10 2019 2020 for g10 by eng.osama ghandour
Css week10 2019 2020 for g10 by eng.osama ghandourCss week10 2019 2020 for g10 by eng.osama ghandour
Css week10 2019 2020 for g10 by eng.osama ghandour
Osama Ghandour Geris
 
Ad

More from Shay Howe (9)

Yes, Designer, You CAN Be a Product Leader
Yes, Designer, You CAN Be a Product LeaderYes, Designer, You CAN Be a Product Leader
Yes, Designer, You CAN Be a Product Leader
Shay Howe
 
Collaboration Practices
Collaboration PracticesCollaboration Practices
Collaboration Practices
Shay Howe
 
How Constraints Cultivate Growth
How Constraints Cultivate GrowthHow Constraints Cultivate Growth
How Constraints Cultivate Growth
Shay Howe
 
UI Design with HTML5 & CSS3
UI Design with HTML5 & CSS3UI Design with HTML5 & CSS3
UI Design with HTML5 & CSS3
Shay Howe
 
HTML5 Semantics
HTML5 SemanticsHTML5 Semantics
HTML5 Semantics
Shay Howe
 
An Intro to HTML & CSS
An Intro to HTML & CSSAn Intro to HTML & CSS
An Intro to HTML & CSS
Shay Howe
 
Quality Development with HTML5
Quality Development with HTML5Quality Development with HTML5
Quality Development with HTML5
Shay Howe
 
The Web Design Process: A Strategy for Success
The Web Design Process: A Strategy for SuccessThe Web Design Process: A Strategy for Success
The Web Design Process: A Strategy for Success
Shay Howe
 
Writing for the Web: The Right Strategy
Writing for the Web: The Right StrategyWriting for the Web: The Right Strategy
Writing for the Web: The Right Strategy
Shay Howe
 
Yes, Designer, You CAN Be a Product Leader
Yes, Designer, You CAN Be a Product LeaderYes, Designer, You CAN Be a Product Leader
Yes, Designer, You CAN Be a Product Leader
Shay Howe
 
Collaboration Practices
Collaboration PracticesCollaboration Practices
Collaboration Practices
Shay Howe
 
How Constraints Cultivate Growth
How Constraints Cultivate GrowthHow Constraints Cultivate Growth
How Constraints Cultivate Growth
Shay Howe
 
UI Design with HTML5 & CSS3
UI Design with HTML5 & CSS3UI Design with HTML5 & CSS3
UI Design with HTML5 & CSS3
Shay Howe
 
HTML5 Semantics
HTML5 SemanticsHTML5 Semantics
HTML5 Semantics
Shay Howe
 
An Intro to HTML & CSS
An Intro to HTML & CSSAn Intro to HTML & CSS
An Intro to HTML & CSS
Shay Howe
 
Quality Development with HTML5
Quality Development with HTML5Quality Development with HTML5
Quality Development with HTML5
Shay Howe
 
The Web Design Process: A Strategy for Success
The Web Design Process: A Strategy for SuccessThe Web Design Process: A Strategy for Success
The Web Design Process: A Strategy for Success
Shay Howe
 
Writing for the Web: The Right Strategy
Writing for the Web: The Right StrategyWriting for the Web: The Right Strategy
Writing for the Web: The Right Strategy
Shay Howe
 
Ad

Recently uploaded (20)

_Basic Geometrik block presentation.pptx
_Basic Geometrik block presentation.pptx_Basic Geometrik block presentation.pptx
_Basic Geometrik block presentation.pptx
ssuserdf2edf
 
Presentation mockup using lots of animals
Presentation mockup using lots of animalsPresentation mockup using lots of animals
Presentation mockup using lots of animals
ChunChihChenPhD
 
Naan mudalvan assignment for students_064143.pptx
Naan mudalvan assignment for  students_064143.pptxNaan mudalvan assignment for  students_064143.pptx
Naan mudalvan assignment for students_064143.pptx
NaziaFarheen13
 
Templates Wind Generator.pdf ahí. Ais d Ai d f
Templates Wind Generator.pdf ahí. Ais d Ai d fTemplates Wind Generator.pdf ahí. Ais d Ai d f
Templates Wind Generator.pdf ahí. Ais d Ai d f
jeremysegundob
 
SEMINAR 2.pptx on the optical behaviours
SEMINAR 2.pptx on the optical behavioursSEMINAR 2.pptx on the optical behaviours
SEMINAR 2.pptx on the optical behaviours
sanhithasanni
 
325295919-AAC-Blocks-Seminar-Presentation.pdf
325295919-AAC-Blocks-Seminar-Presentation.pdf325295919-AAC-Blocks-Seminar-Presentation.pdf
325295919-AAC-Blocks-Seminar-Presentation.pdf
shivsin165
 
MOCCAE SUSTAINABLE TROPHY 2025 Presentation.pdf
MOCCAE SUSTAINABLE TROPHY 2025 Presentation.pdfMOCCAE SUSTAINABLE TROPHY 2025 Presentation.pdf
MOCCAE SUSTAINABLE TROPHY 2025 Presentation.pdf
asfianoor1
 
behiriskfactorsxyzkskeb210217133906 (1).pdf
behiriskfactorsxyzkskeb210217133906 (1).pdfbehiriskfactorsxyzkskeb210217133906 (1).pdf
behiriskfactorsxyzkskeb210217133906 (1).pdf
ShakibulHasan14
 
Baby panda 400.pdf de ciencias naturales
Baby panda 400.pdf de ciencias naturalesBaby panda 400.pdf de ciencias naturales
Baby panda 400.pdf de ciencias naturales
debbie loaiza
 
4K Video Downloader Crack (2025) + License Key Free
4K Video Downloader Crack (2025) + License Key Free4K Video Downloader Crack (2025) + License Key Free
4K Video Downloader Crack (2025) + License Key Free
Designer
 
An updated content measurement model - Elle Geraghty Content Strategy.pdf
An updated content measurement model - Elle Geraghty Content Strategy.pdfAn updated content measurement model - Elle Geraghty Content Strategy.pdf
An updated content measurement model - Elle Geraghty Content Strategy.pdf
Elle Geraghty
 
01 How Colors Affect Human Behavior - 2025.pdf
01 How Colors Affect Human Behavior - 2025.pdf01 How Colors Affect Human Behavior - 2025.pdf
01 How Colors Affect Human Behavior - 2025.pdf
amensamer76
 
PayPros-Journey-Overcoming-Challenges-Through-Governance.pptx
PayPros-Journey-Overcoming-Challenges-Through-Governance.pptxPayPros-Journey-Overcoming-Challenges-Through-Governance.pptx
PayPros-Journey-Overcoming-Challenges-Through-Governance.pptx
rayyansiddiqui034
 
Steam-Education-PowerPoint-Templates.pptx
Steam-Education-PowerPoint-Templates.pptxSteam-Education-PowerPoint-Templates.pptx
Steam-Education-PowerPoint-Templates.pptx
andripapa1
 
dFdDVWeb_Design_Basics_Presentation.pptx
dFdDVWeb_Design_Basics_Presentation.pptxdFdDVWeb_Design_Basics_Presentation.pptx
dFdDVWeb_Design_Basics_Presentation.pptx
AKSHAYKAMBLE806728
 
PPT -MBI_07 .pptx final to present today
PPT -MBI_07 .pptx final to present todayPPT -MBI_07 .pptx final to present today
PPT -MBI_07 .pptx final to present today
nikhilpanchal510
 
𝗗𝗲𝘀𝗶𝗴𝗻𝗶𝗻𝗴 𝗳𝗼𝗿 𝗮𝗹𝗹: 𝗜𝗻𝗰𝗹𝘂𝘀𝗶𝘃𝗲 𝗣𝗿𝗮𝗰𝘁𝗶𝗰𝗲 𝗳𝗼𝗿 𝗕𝗲𝘁𝘁𝗲𝗿 𝗘𝘅𝗽𝗲𝗿𝗶𝗲𝗻𝗰𝗲𝘀
𝗗𝗲𝘀𝗶𝗴𝗻𝗶𝗻𝗴 𝗳𝗼𝗿 𝗮𝗹𝗹: 𝗜𝗻𝗰𝗹𝘂𝘀𝗶𝘃𝗲 𝗣𝗿𝗮𝗰𝘁𝗶𝗰𝗲 𝗳𝗼𝗿 𝗕𝗲𝘁𝘁𝗲𝗿 𝗘𝘅𝗽𝗲𝗿𝗶𝗲𝗻𝗰𝗲𝘀𝗗𝗲𝘀𝗶𝗴𝗻𝗶𝗻𝗴 𝗳𝗼𝗿 𝗮𝗹𝗹: 𝗜𝗻𝗰𝗹𝘂𝘀𝗶𝘃𝗲 𝗣𝗿𝗮𝗰𝘁𝗶𝗰𝗲 𝗳𝗼𝗿 𝗕𝗲𝘁𝘁𝗲𝗿 𝗘𝘅𝗽𝗲𝗿𝗶𝗲𝗻𝗰𝗲𝘀
𝗗𝗲𝘀𝗶𝗴𝗻𝗶𝗻𝗴 𝗳𝗼𝗿 𝗮𝗹𝗹: 𝗜𝗻𝗰𝗹𝘂𝘀𝗶𝘃𝗲 𝗣𝗿𝗮𝗰𝘁𝗶𝗰𝗲 𝗳𝗼𝗿 𝗕𝗲𝘁𝘁𝗲𝗿 𝗘𝘅𝗽𝗲𝗿𝗶𝗲𝗻𝗰𝗲𝘀
Friends of Figm a, Sydney
 
Lori Vanzant Online Presence. Take a look!
Lori Vanzant Online Presence. Take a look!Lori Vanzant Online Presence. Take a look!
Lori Vanzant Online Presence. Take a look!
vanzan01
 
Internet Download Manager Crack Patch Latest IDM Free Download
Internet Download Manager Crack Patch Latest IDM Free DownloadInternet Download Manager Crack Patch Latest IDM Free Download
Internet Download Manager Crack Patch Latest IDM Free Download
Designer
 
10.1155-2024-1048933Figurefig0008.pptx.ppt
10.1155-2024-1048933Figurefig0008.pptx.ppt10.1155-2024-1048933Figurefig0008.pptx.ppt
10.1155-2024-1048933Figurefig0008.pptx.ppt
suchandasaha7
 
_Basic Geometrik block presentation.pptx
_Basic Geometrik block presentation.pptx_Basic Geometrik block presentation.pptx
_Basic Geometrik block presentation.pptx
ssuserdf2edf
 
Presentation mockup using lots of animals
Presentation mockup using lots of animalsPresentation mockup using lots of animals
Presentation mockup using lots of animals
ChunChihChenPhD
 
Naan mudalvan assignment for students_064143.pptx
Naan mudalvan assignment for  students_064143.pptxNaan mudalvan assignment for  students_064143.pptx
Naan mudalvan assignment for students_064143.pptx
NaziaFarheen13
 
Templates Wind Generator.pdf ahí. Ais d Ai d f
Templates Wind Generator.pdf ahí. Ais d Ai d fTemplates Wind Generator.pdf ahí. Ais d Ai d f
Templates Wind Generator.pdf ahí. Ais d Ai d f
jeremysegundob
 
SEMINAR 2.pptx on the optical behaviours
SEMINAR 2.pptx on the optical behavioursSEMINAR 2.pptx on the optical behaviours
SEMINAR 2.pptx on the optical behaviours
sanhithasanni
 
325295919-AAC-Blocks-Seminar-Presentation.pdf
325295919-AAC-Blocks-Seminar-Presentation.pdf325295919-AAC-Blocks-Seminar-Presentation.pdf
325295919-AAC-Blocks-Seminar-Presentation.pdf
shivsin165
 
MOCCAE SUSTAINABLE TROPHY 2025 Presentation.pdf
MOCCAE SUSTAINABLE TROPHY 2025 Presentation.pdfMOCCAE SUSTAINABLE TROPHY 2025 Presentation.pdf
MOCCAE SUSTAINABLE TROPHY 2025 Presentation.pdf
asfianoor1
 
behiriskfactorsxyzkskeb210217133906 (1).pdf
behiriskfactorsxyzkskeb210217133906 (1).pdfbehiriskfactorsxyzkskeb210217133906 (1).pdf
behiriskfactorsxyzkskeb210217133906 (1).pdf
ShakibulHasan14
 
Baby panda 400.pdf de ciencias naturales
Baby panda 400.pdf de ciencias naturalesBaby panda 400.pdf de ciencias naturales
Baby panda 400.pdf de ciencias naturales
debbie loaiza
 
4K Video Downloader Crack (2025) + License Key Free
4K Video Downloader Crack (2025) + License Key Free4K Video Downloader Crack (2025) + License Key Free
4K Video Downloader Crack (2025) + License Key Free
Designer
 
An updated content measurement model - Elle Geraghty Content Strategy.pdf
An updated content measurement model - Elle Geraghty Content Strategy.pdfAn updated content measurement model - Elle Geraghty Content Strategy.pdf
An updated content measurement model - Elle Geraghty Content Strategy.pdf
Elle Geraghty
 
01 How Colors Affect Human Behavior - 2025.pdf
01 How Colors Affect Human Behavior - 2025.pdf01 How Colors Affect Human Behavior - 2025.pdf
01 How Colors Affect Human Behavior - 2025.pdf
amensamer76
 
PayPros-Journey-Overcoming-Challenges-Through-Governance.pptx
PayPros-Journey-Overcoming-Challenges-Through-Governance.pptxPayPros-Journey-Overcoming-Challenges-Through-Governance.pptx
PayPros-Journey-Overcoming-Challenges-Through-Governance.pptx
rayyansiddiqui034
 
Steam-Education-PowerPoint-Templates.pptx
Steam-Education-PowerPoint-Templates.pptxSteam-Education-PowerPoint-Templates.pptx
Steam-Education-PowerPoint-Templates.pptx
andripapa1
 
dFdDVWeb_Design_Basics_Presentation.pptx
dFdDVWeb_Design_Basics_Presentation.pptxdFdDVWeb_Design_Basics_Presentation.pptx
dFdDVWeb_Design_Basics_Presentation.pptx
AKSHAYKAMBLE806728
 
PPT -MBI_07 .pptx final to present today
PPT -MBI_07 .pptx final to present todayPPT -MBI_07 .pptx final to present today
PPT -MBI_07 .pptx final to present today
nikhilpanchal510
 
𝗗𝗲𝘀𝗶𝗴𝗻𝗶𝗻𝗴 𝗳𝗼𝗿 𝗮𝗹𝗹: 𝗜𝗻𝗰𝗹𝘂𝘀𝗶𝘃𝗲 𝗣𝗿𝗮𝗰𝘁𝗶𝗰𝗲 𝗳𝗼𝗿 𝗕𝗲𝘁𝘁𝗲𝗿 𝗘𝘅𝗽𝗲𝗿𝗶𝗲𝗻𝗰𝗲𝘀
𝗗𝗲𝘀𝗶𝗴𝗻𝗶𝗻𝗴 𝗳𝗼𝗿 𝗮𝗹𝗹: 𝗜𝗻𝗰𝗹𝘂𝘀𝗶𝘃𝗲 𝗣𝗿𝗮𝗰𝘁𝗶𝗰𝗲 𝗳𝗼𝗿 𝗕𝗲𝘁𝘁𝗲𝗿 𝗘𝘅𝗽𝗲𝗿𝗶𝗲𝗻𝗰𝗲𝘀𝗗𝗲𝘀𝗶𝗴𝗻𝗶𝗻𝗴 𝗳𝗼𝗿 𝗮𝗹𝗹: 𝗜𝗻𝗰𝗹𝘂𝘀𝗶𝘃𝗲 𝗣𝗿𝗮𝗰𝘁𝗶𝗰𝗲 𝗳𝗼𝗿 𝗕𝗲𝘁𝘁𝗲𝗿 𝗘𝘅𝗽𝗲𝗿𝗶𝗲𝗻𝗰𝗲𝘀
𝗗𝗲𝘀𝗶𝗴𝗻𝗶𝗻𝗴 𝗳𝗼𝗿 𝗮𝗹𝗹: 𝗜𝗻𝗰𝗹𝘂𝘀𝗶𝘃𝗲 𝗣𝗿𝗮𝗰𝘁𝗶𝗰𝗲 𝗳𝗼𝗿 𝗕𝗲𝘁𝘁𝗲𝗿 𝗘𝘅𝗽𝗲𝗿𝗶𝗲𝗻𝗰𝗲𝘀
Friends of Figm a, Sydney
 
Lori Vanzant Online Presence. Take a look!
Lori Vanzant Online Presence. Take a look!Lori Vanzant Online Presence. Take a look!
Lori Vanzant Online Presence. Take a look!
vanzan01
 
Internet Download Manager Crack Patch Latest IDM Free Download
Internet Download Manager Crack Patch Latest IDM Free DownloadInternet Download Manager Crack Patch Latest IDM Free Download
Internet Download Manager Crack Patch Latest IDM Free Download
Designer
 
10.1155-2024-1048933Figurefig0008.pptx.ppt
10.1155-2024-1048933Figurefig0008.pptx.ppt10.1155-2024-1048933Figurefig0008.pptx.ppt
10.1155-2024-1048933Figurefig0008.pptx.ppt
suchandasaha7
 

Modular HTML & CSS Workshop

  • 1. TACTICAL HTML & CSS Shay Howe @shayhowe learn.shayhowe.com MODULAR HTML & CSS WORKSHOP
  • 2. @shayhoweModular HTML & CSS Shay Howe @shayhowe learn.shayhowe.com
  • 3. @shayhoweModular HTML & CSS 1. The Problem 2. Groundwork 3. Assembling Layout 4. Accommodating Content 5. Onward OUR SCHEDULE
  • 4. @shayhoweModular HTML & CSS THE PROBLEM
  • 5. The Gust by Willem van de Velde the Younger
  • 6. @shayhoweModular HTML & CSS COMMON PROBLEMS • Websites have difficulty scaling • Code becomes brittle • Files and code bases begin to swell
  • 7. @shayhoweModular HTML & CSS WHAT’S WRONG • Best practices aren’t exactly best practices • Standards need to evolve
  • 8. @shayhoweModular HTML & CSS BEST BAD PRACTICES • Avoid extra elements • Avoid classes • Leverage type selectors • Leverage descendent selectors
  • 9. @shayhoweModular HTML & CSS BEST BAD PRACTICES Avoiding classes section  ul#nav  li  {...} section:nth-­‐child(2)  div:nth-­‐child(7)  >  a  {...} Leveraging selectors a.btn  {...} #main  a.btn  {...} #main  div.feature  a.btn  {...}
  • 10. @shayhoweModular HTML & CSS BEST BAD PRACTICES Bad #contact  li:nth-­‐child(1)  input, #contact  li:nth-­‐child(2)  input  {    width:  160px; } #contact  li:nth-­‐child(3)  textarea  {    width:  280px; }
  • 11. @shayhoweModular HTML & CSS BEST BAD PRACTICES Good .col-­‐1  {    width:  160px; } .col-­‐2  {    width:  280px; }
  • 12. @shayhoweModular HTML & CSS SPECIFICITY? • Specificity determines which styles are applied • Each selector has a specificity weight • High specificity beats low specificity • Low specificity is key
  • 13. @shayhoweModular HTML & CSS MEASURING SPECIFICITY Formula • IDs, Classes/Pseudo-classes/Attributes, Elements High Specificity (Bad) #primary  #main  div.gallery  figure.media IDs: 2, Classes: 2, Elements: 2 — Compiled: 2–2–2 Low Specificity (Good) .gallery-­‐media IDs: 0, Classes: 1, Elements: 0 — Compiled: 0–1–0
  • 15. @shayhoweModular HTML & CSS WATCH SPECIFICITY • Be explicit • Keep specificity low • Never use IDs or !important • Avoid nested selectors (#main  .spotlight  strong  span)
  • 16. @shayhoweModular HTML & CSS WATCH SPECIFICITY Bad #primary  #main  div.gallery  {    text-­‐transform:  uppercase; } #primary  #main  div.gallery  figure.media  {    background:  #ccc; }
  • 17. @shayhoweModular HTML & CSS WATCH SPECIFICITY Good .gallery  {    text-­‐transform:  uppercase; } .gallery-­‐media  {    background:  #ccc; }
  • 18. Parade of the Black Sea Fleet by Ivan Aivazovsky
  • 19. @shayhoweModular HTML & CSS MAINTAINABILITY Code must be... • Organized • Modular • Performant
  • 20. @shayhoweModular HTML & CSS METHODOLOGIES OOCSS • Object-Oriented CSS From Nicole Sullivan – oocss.org SMACSS • Scalable and Modular Architecture for CSS From Jonathan Snook – smacss.com
  • 21. @shayhoweModular HTML & CSS GROUNDWORK
  • 22. @shayhoweModular HTML & CSS REUSE CODE • Do not duplicate code • Remove old code • Defer loading subsequent styles
  • 23. @shayhoweModular HTML & CSS REUSE CODE Bad .news  {    background:  #eee;    color:  #666; } .social  {    background:  #eee;    color:  #666; }
  • 24. @shayhoweModular HTML & CSS REUSE CODE Good .news, .social  {    background:  #eee;    color:  #666; } Better .feat-­‐box  {    background:  #eee;    color:  #666; }
  • 25. @shayhoweModular HTML & CSS USE CLASSES • Write understandable class names • Avoid unnecessary nesting • Use same strength specificity
  • 26. @shayhoweModular HTML & CSS USE CLASSES Bad .feat-­‐box  .callout  .pr  {    font-­‐size:  12px; } .feat-­‐box  .callout  .pr  .un  {    color:  #39f; }
  • 27. @shayhoweModular HTML & CSS USE CLASSES Good .feat-­‐box  .price  {    font-­‐size:  12px; } .feat-­‐box  .unit  {    color:  #39f; }
  • 28. @shayhoweModular HTML & CSS USE CLASSES Bad .btn.large  {    font-­‐size:  24px;        padding:  15px  30px; } <div  class="btn  large">...</div>
  • 29. @shayhoweModular HTML & CSS USE CLASSES Good .btn-­‐large  {    font-­‐size:  24px;    padding:  15px  30px; } <div  class="btn-­‐large">...</div>
  • 30. @shayhoweModular HTML & CSS ASSEMBLING LAYOUT
  • 31. @shayhoweModular HTML & CSS ABSTRACT STRUCTURE • Separate presentation (or theme) from layout • Create an object layer for layout • Create a skin layer for theme • Use a grid
  • 32. @shayhoweModular HTML & CSS ABSTRACT STRUCTURE Bad .news  {    background:  #eee;    color:  #666;    margin:  0  10px;    width:  400px; } <div  class="news">...</div>
  • 33. @shayhoweModular HTML & CSS ABSTRACT STRUCTURE Good .grid-­‐4  {    margin:  0  10px;    width:  400px; } .feat-­‐box  {    background:  #eee;    color:  #666; } <div  class="grid-­‐4  feat-­‐box">...</div>
  • 34. @shayhoweModular HTML & CSS TRANSPARENTIZE ELEMENTS • Stylize elements to be transparent • Keep visual properties apart from layout properties
  • 35. @shayhoweModular HTML & CSS TRANSPARENTIZE ELEMENTS Bad .pagination  {    border-­‐radius:  5px;    border:  1px  solid  #eee;    margin:  0  10px;    width:  620px; } <ul  class="pagination">...</ul>
  • 36. @shayhoweModular HTML & CSS TRANSPARENTIZE ELEMENTS Good .grid-­‐8  {    margin:  0  10px;    width:  620px; } .offset-­‐box  {    border-­‐radius:  5px;    border:  1px  solid  #eee; } <ul  class="grid-­‐8  offset-­‐box">...</ul>
  • 37. @shayhoweModular HTML & CSS CREATE ADAPTABLE LAYOUTS • Height and width should be flexible • Height should extend with content • Width should extend with a grid
  • 38. @shayhoweModular HTML & CSS CREATE ADAPTABLE LAYOUTS Bad #main  {    float:  left;    margin:  0  10px;    width:  620px; } #aside  {    float:  left;    margin:  0  10px;    width:  300px; }
  • 39. @shayhoweModular HTML & CSS CREATE ADAPTABLE LAYOUTS Good .grid-­‐4, .grid-­‐8  {    float:  left;    margin:  0  10px; } .grid-­‐4  {    width:  300px; } .grid-­‐8  {    width:  620px; }
  • 40. @shayhoweModular HTML & CSS ASSEMBLING LAYOUT IN PRACTICE http://bit.ly/modular-html-css
  • 41. @shayhoweModular HTML & CSS ACCOMMODATING CONTENT
  • 42. @shayhoweModular HTML & CSS SEPARATE CONTENT • Separate content from container • Stylize content regardless of container
  • 43. @shayhoweModular HTML & CSS SEPARATE CONTENT Bad .alert  {    background:  #f2dede;    border-­‐radius:  10px;    color:  #b94a48;    padding:  10px  20px; } <div  class="alert">...</div>
  • 44. @shayhoweModular HTML & CSS SEPARATE CONTENT Good .alert  {    border-­‐radius:  10px;    padding:  10px  20px; } .alert-­‐error  {    background:  #f2dede;    color:  #b94a48; } <div  class="alert  alert-­‐error">...</div>
  • 45. @shayhoweModular HTML & CSS AVOID PARENT DEPENDENCY • Remove parent container dependency • Decouple CSS from HTML • Create components to be used anywhere
  • 46. @shayhoweModular HTML & CSS AVOID PARENT DEPENDENCY Bad .feat-­‐box  {    background:  #eee; } article  .feat-­‐box  {    background:  #fff; } <article>    <div  class="feat-­‐box">...</div> </article>
  • 47. @shayhoweModular HTML & CSS AVOID PARENT DEPENDENCY Good .feat-­‐box  {    background:  #eee; } .feat-­‐box-­‐alt  {    background:  #fff; } <article>    <div  class="feat-­‐box-­‐alt">...</div> </article>
  • 48. @shayhoweModular HTML & CSS FAVOR SEMANTICS • Allow elements to adapt • Uses individual classes to extend modules
  • 49. @shayhoweModular HTML & CSS FAVOR SEMANTICS Bad .feat-­‐box  h2  {    color:  #f60;    font:  18px  Helvetica,  sans-­‐serif; } <div  class="feat-­‐box">    <h2>...</h2> </div>
  • 50. @shayhoweModular HTML & CSS FAVOR SEMANTICS Good .feat-­‐subhead  {    color:  #f60;    font:  18px  Helvetica,  sans-­‐serif; } <div  class="feat-­‐box">    <h2  class="feat-­‐subhead">...</h2> </div>
  • 51. @shayhoweModular HTML & CSS ACCOMMODATING CONTENT IN PRACTICE http://bit.ly/modular-html-css
  • 53. Ships on the Roadstead by Willem van de Velde the Younger
  • 54. @shayhoweModular HTML & CSS APPROACH • Stop thinking about pages • Start thinking about components • Take visual inventory
  • 55. @shayhoweModular HTML & CSS THEMES • Decouple HTML and CSS • Separate presentation from layout • Separate content from container • Extend elements with classes
  • 56. @shayhoweModular HTML & CSS OUTCOMES • Maintainability! • Reusable code, less duplication • Flexibility and extensibility • Improved standards
  • 57. @shayhoweModular HTML & CSS WHAT’S NEXT Build a styleguide • Twitter Bootstrap, Zurb Foundation Review methodologies • OOCSS, SMACSS Test your code • CSS Lint, Inspector, PageSpeed
  • 58. @shayhoweModular HTML & CSS THANK YOU! Questions? @shayhowe http://learn.shayhowe.com