SlideShare a Scribd company logo
Object Oriented CSS

                      Graeme Blackwood
                      Creative Director
                      Deeson Online
                      twitter.com/graemeblackwood
Спонсоры
     Организатор      Генеральный спонсор




 Серебряный спонсор   Серебряный спонсор




 Бронзовый спонсор     Бронзовый спонсор




                                    2
Graeme Blackwood
Creative Director, Deeson Online


deeson-online.co.uk
@graemeblackwood
Object
Oriented
CSS
Props
•   Nicole Sullivan, http://www.stubbornella.org

•   Jonathan Snook (SMACSS), http://smacss.com

•   Everyone at http://thesassway.com

•   Chris Eppstein, http://compass-style.org

•   Kevin Poulton http://www.flickr.com/photos/kevinpoulton

•   And loads more!
Some misconceptions
OO CSS !=
OO Programming

But an OOP mindset can be 
applied to CSS
OOCSS does not
require any newer
technologies

It works in IE6 – no need for CSS3, 
HTML5 etc
Semantic markup is
very helpful, but
usually not essential

Semantic is better though!
The traditional approach
        to CSS
Style output
as needed
Each item / page 
individually...
Target styles by
drilling down
through nested
elements
Problems with
traditional CSS
Coding takes
a lot longer
It gets
bloated
It is difficult to read
and hard to reuse
Traditional CSS is
tough to maintain
Object oriented css. Graeme Blackwood
Object Oriented CSS
A new way of thinking
Separate layout from theme(Use 
a grid system!)
Separate the container
from the content
Look for shared styles
You will see them everywhere
Why should
I care?
Reusable code
Object oriented css. Graeme Blackwood
Faster
development
                        QuickTime™ and a
                      H.264 decompressor
                 are needed to see this picture.




Less effort to code
Easier to maintain
Object oriented css. Graeme Blackwood
Object oriented css. Graeme Blackwood
Less code,
smaller files
Getting started
Using a grid system?
You are already on the right track!
Use a reset
stylesheet
HTML5 boilerplate’s 
normalize.css
Set good base styles
To minimise later overrides

* {box­sizing: border­box} is pretty handy
Buildgood base stylesTo 
Set HTML prototypeswith 
Drupal in mind...
minimise later overrides
Clean up what Drupal
throws at you
Don’t just style,
theme!
Lose unnecessary
markup if it affects you
             Some divs are 
             totally pointless!
PHP code not for you?
I find Drupal modules like
Display Suite and Skinr helpful
Check out TWIG
We’re working on making Drupal 8 a lot 
easier to theme.

http://twig.sensiolabs.org/
Don’t be too obsessed
with perfect markup
Just enough is ok
“Now, this is just a simulation of what the blocks 
    will look like once they’re assembled”
Let’s look at some real
world applications...
.block = inherited base styles only.grid-4 = grid class.theme-a = theme
class, H3 and p inherit colour.padded is a class I add to the grid
framework for situations like this
<div class=”grid-4 theme-a block”>
  <h3>Block title</h3>
  <p>Hello world!</p>
</div>




.grid-4 comes from your grid framework

.theme-a {
  background-color: #580174;
  border-radius: 6px;
  color: #fff; //H3 and p inherit this
}
Carousel nav tabsObject is a Drupal menu 
– UL with a class of .sidebar­menu. Custom jQuery targets the ID.
Also used on a listingAnd it f
the container
99% of the styles are reused,
targeted through .right
.sidebar-menu only to flip the
active item
Carousel items
With a class of .product­box
Reused on listing
pages
Same layout as product
listings and carousel, flexed
to image size
What about
SASS and LESS?
Why bother with presentational classes 
in markup anymore?
Not everyone wants to use a CSS preprocessorAnd the mindset of reduce, reuse & recycle is just as important even with one
Use SASS wisely – it’s
another layer to debug
Be particularly careful
with nested selectors
http://thesassway.com/beginner/the­inception­rule

http://37signals.com/svn/posts/3003­css­taking­control­of­the­cascade
Object oriented css. Graeme Blackwood
Disregarding the other
principles of OOCSS may
create pain later
You could end up with generated CSS bloated 
even more than if you had hand­coded it
Summary
•   OOCSS is as much a mindset as a technique

•   The principles are to reduce, reuse and recycle code

•   This is done through separating layout from theme

•   and the container from the content

•   It relies primarily on reused classes and markup

•   We are working on Drupal 8 to make it much easier to
    change markup. In the meantime, try Display Suite or Skinr
    for node theming
Summary

•   CSS preprocessors like SASS and LESS are great

•   But they create another layer to debug

•   And the code they generate can be very bloated

•   Preprocessors are not an excuse to be lazy

•   They still need to be used with an OO mindset
Спасибо за внимание

Вопросы?
            Graeme Blackwood
            Creative Director
            Deeson Online
            @graemeblackwood
Спонсоры
     Организатор      Генеральный спонсор




 Серебряный спонсор   Серебряный спонсор




 Бронзовый спонсор     Бронзовый спонсор




                                    60

More Related Content

PPTX
Tweaking your Template: Joomla Day Boston 2014 Barb Ackemann
PDF
What's Object-Oriented CSS (japanese)
KEY
Make your website 2 times faster
PDF
Developing Your Ultimate Package
PPTX
BDUG Responsive Web Theming - 7/23/12
PPTX
Introduction to Custom WordPress Themeing
PPTX
Building a WordPress theme
PPTX
Basics of Front End Web Dev PowerPoint
Tweaking your Template: Joomla Day Boston 2014 Barb Ackemann
What's Object-Oriented CSS (japanese)
Make your website 2 times faster
Developing Your Ultimate Package
BDUG Responsive Web Theming - 7/23/12
Introduction to Custom WordPress Themeing
Building a WordPress theme
Basics of Front End Web Dev PowerPoint

What's hot (19)

PDF
The way to be a developer "What I Need"
PDF
The web context
ODP
Drupal distributions - how to build them
PDF
CSS Modules
PDF
CSS Systems
PDF
Lightning fast sass
PDF
Battle of the Front-End Frameworks: Bootstrap vs. Foundation
PDF
Be nice to your designers
PDF
Adobe Source 2016 - Styleguides and AEM
PPTX
HTML/CSS Workshop @ Searchcamp
PDF
WordPress Theme Structure
PDF
Efficient, maintainable CSS
PDF
Frontend django, Django Web 前端探索
PDF
Designing with Drupal 8
PPTX
Hammersmith fundamentals html fundamentals
PPS
Introduction to Bootstrap: Design for Developers
PDF
Steve Barman - CSS and WordPress
PDF
網頁程式設計
The way to be a developer "What I Need"
The web context
Drupal distributions - how to build them
CSS Modules
CSS Systems
Lightning fast sass
Battle of the Front-End Frameworks: Bootstrap vs. Foundation
Be nice to your designers
Adobe Source 2016 - Styleguides and AEM
HTML/CSS Workshop @ Searchcamp
WordPress Theme Structure
Efficient, maintainable CSS
Frontend django, Django Web 前端探索
Designing with Drupal 8
Hammersmith fundamentals html fundamentals
Introduction to Bootstrap: Design for Developers
Steve Barman - CSS and WordPress
網頁程式設計
Ad

Viewers also liked (7)

PPT
Drush and drupal. администрирование. Волчек Михаил
PPT
Drupal and the keys to successful communities. Martin Mayer
PPT
Практическое использование модуля Panels. Богуцкий Виктор
PPTX
Album cover planning
PPTX
Album cover final
PPTX
Michael turner a2 media coursework
PDF
Lessons from the movie lagaan
Drush and drupal. администрирование. Волчек Михаил
Drupal and the keys to successful communities. Martin Mayer
Практическое использование модуля Panels. Богуцкий Виктор
Album cover planning
Album cover final
Michael turner a2 media coursework
Lessons from the movie lagaan
Ad

Similar to Object oriented css. Graeme Blackwood (20)

PPT
Object oriented css graeme blackwood
PDF
Object Oriented CSS for rapid, scalable and maintainable development
PPTX
Css methods architecture
PPTX
Elegant CSS Design In Drupal: LESS vs Sass
PDF
ZURB Foundation 5: Clean + Organized
ZIP
OOCSS for Javascript pirates at jQueryPgh meetup
PDF
Decoupling the Front-end with Modular CSS
PDF
OOCSS for JavaScript Pirates jQcon Boston
PDF
DRY CSS A don’t-repeat-yourself methodology for creating efficient, unified a...
PDF
Atlanta Drupal User's Group - April 2015 - Sasstronauts: Advanced Sass Topics
PDF
SASS, Compass, Gulp, Greensock
PDF
Future-proof styling in Drupal (8)
PDF
Death of a Themer
KEY
Slow kinda sucks
PDF
Intro to OOCSS Workshop
PPTX
Branding SharePoint from Prototype to Deployment - Workshop
PPTX
SASS is more than LESS
PDF
Object Oriented CSS - Joomla!dagen Nederland 2014
PPTX
OOCSS presentation
PDF
Newfangeldy Front End Stuff For People Who Last Touched It Back When Grunge W...
Object oriented css graeme blackwood
Object Oriented CSS for rapid, scalable and maintainable development
Css methods architecture
Elegant CSS Design In Drupal: LESS vs Sass
ZURB Foundation 5: Clean + Organized
OOCSS for Javascript pirates at jQueryPgh meetup
Decoupling the Front-end with Modular CSS
OOCSS for JavaScript Pirates jQcon Boston
DRY CSS A don’t-repeat-yourself methodology for creating efficient, unified a...
Atlanta Drupal User's Group - April 2015 - Sasstronauts: Advanced Sass Topics
SASS, Compass, Gulp, Greensock
Future-proof styling in Drupal (8)
Death of a Themer
Slow kinda sucks
Intro to OOCSS Workshop
Branding SharePoint from Prototype to Deployment - Workshop
SASS is more than LESS
Object Oriented CSS - Joomla!dagen Nederland 2014
OOCSS presentation
Newfangeldy Front End Stuff For People Who Last Touched It Back When Grunge W...

More from PVasili (20)

PDF
Как зарабатывать друпал разработчику. Клют Иван
PPT
Easy authcache 2 кэширование для pro. Родионов Игорь
PPT
Business friendly Drupal, Павел Прищепа
PPT
построение внутренней ссылочной структуры сайта на Drupal 7 (seo). Костин ...
PPT
инструкция по оптимизации сайтов на Drupal херени даниэл
PPT
фотосток на Drupal+maestro Житарёв Антон
PPT
Непрерывная интеграция шаг к непрерывному деплою. Родионов Игорь
PPT
Drupal и мобильные устройства, Комелин Константин
PPT
Кеширование на высоконагруженном Drupal сайте. Архаров Роман
PPTX
Опыт построения компании-разработчика Интернет проектов на Drupal
PPT
Свой проект на drupal.org от идеи до первого релиза.
PPT
Интеграция Яндекс Сервер
PPTX
Microsoft , Azure и Drupal
PDF
Нагрузочное тестирование проектов на Drupal с использованием Apache JMeter
PDF
Поисковая оптимизация интернет-магазины на базе Drupal Commerce
PPTX
Инструментарий продвинутого командного разработчика
PPTX
Приём платежей для CMS
PDF
Системы управления взаимоотношениями с клиентами. Drupal CRM.
PPT
Увеличение качества и прибыльности проекта для разработчика.
PDF
Drupal vs Бизнес: почему Drupal лучше любого framework и как его правильно го...
Как зарабатывать друпал разработчику. Клют Иван
Easy authcache 2 кэширование для pro. Родионов Игорь
Business friendly Drupal, Павел Прищепа
построение внутренней ссылочной структуры сайта на Drupal 7 (seo). Костин ...
инструкция по оптимизации сайтов на Drupal херени даниэл
фотосток на Drupal+maestro Житарёв Антон
Непрерывная интеграция шаг к непрерывному деплою. Родионов Игорь
Drupal и мобильные устройства, Комелин Константин
Кеширование на высоконагруженном Drupal сайте. Архаров Роман
Опыт построения компании-разработчика Интернет проектов на Drupal
Свой проект на drupal.org от идеи до первого релиза.
Интеграция Яндекс Сервер
Microsoft , Azure и Drupal
Нагрузочное тестирование проектов на Drupal с использованием Apache JMeter
Поисковая оптимизация интернет-магазины на базе Drupal Commerce
Инструментарий продвинутого командного разработчика
Приём платежей для CMS
Системы управления взаимоотношениями с клиентами. Drupal CRM.
Увеличение качества и прибыльности проекта для разработчика.
Drupal vs Бизнес: почему Drupal лучше любого framework и как его правильно го...

Recently uploaded (20)

PDF
MIND Revenue Release Quarter 2 2025 Press Release
PDF
gpt5_lecture_notes_comprehensive_20250812015547.pdf
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PDF
Encapsulation_ Review paper, used for researhc scholars
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PDF
A comparative analysis of optical character recognition models for extracting...
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PPTX
Cloud computing and distributed systems.
PDF
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
PDF
NewMind AI Weekly Chronicles - August'25-Week II
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PDF
Spectral efficient network and resource selection model in 5G networks
PDF
Electronic commerce courselecture one. Pdf
PDF
Approach and Philosophy of On baking technology
PDF
cuic standard and advanced reporting.pdf
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PDF
Encapsulation theory and applications.pdf
PPTX
Programs and apps: productivity, graphics, security and other tools
MIND Revenue Release Quarter 2 2025 Press Release
gpt5_lecture_notes_comprehensive_20250812015547.pdf
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Encapsulation_ Review paper, used for researhc scholars
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
A comparative analysis of optical character recognition models for extracting...
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
Cloud computing and distributed systems.
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
NewMind AI Weekly Chronicles - August'25-Week II
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
Spectral efficient network and resource selection model in 5G networks
Electronic commerce courselecture one. Pdf
Approach and Philosophy of On baking technology
cuic standard and advanced reporting.pdf
Building Integrated photovoltaic BIPV_UPV.pdf
Advanced methodologies resolving dimensionality complications for autism neur...
Encapsulation theory and applications.pdf
Programs and apps: productivity, graphics, security and other tools

Object oriented css. Graeme Blackwood

Editor's Notes

  • #17: Harder to maintain Bloated code is harder to read due to the sheer volume of it If the style of something changes, every instance has to be updated individually, and on bigger sites, this often means something getting missed until the client complains – not cool Adding features to / scaling up a website simply bloats the CSS
  • #19: So what’s the solution?
  • #20: What does this involve?
  • #30: Less likely to break other parts of your site when you change things. Navigating through the code is easier Less conflicting styles Code won’t be littered with importants Scale it right up
  • #31: CEM
  • #32: Your love affair with object oriented CSS is about to begin
  • #33: If not, this is the first step toward OOCSS. It could be a grid system you wrote yourself, or one like 960gs, blueprint etc. In fact, I recommend using a responsive grid system.
  • #34: I probably don’t have to say this... Boilerplate’s CSS works even if you’re not using HTML5 Better than Eric Meyer’s reset.css, which causes problems with Drupal.
  • #35: Good base styles are particularly important for typography. It may even be worth separating your typographic styles into a separate stylesheet. Border-box is incredibly useful for controlling sizes when needing to use padding and borders. And it works in IE7!
  • #36: Focus on getting the code right before tackling Drupal’s way Helps me really understand my frontend code before I theme But think of the developers/themers if you’re not the one doing the implementation
  • #37: Controversial It can feel faster to just style the output and forget about it But this means all the downsides already mentioned will become realities Once classes start going in, the theme falls into place rapidly It is just as fast, and the more you do, the faster it gets
  • #38: Drupal’s output is currently not very semantic Fortunately this is starting to improve thanks to you guys I find Display Suite a massive help, and it is very simple to learn I output views as HTML Lists and then theme them to add my classes
  • #44: Notice how it reads like normal language too
  • #45: The grid-4 class provides the div with its layout styles The theme-a class provides it with its theme Because the base styles for H3s and Ps don’t have colours assigned, they will inherit the colour in the theme
  • #47: It flexes to the container No extra styling, markup changes or classes needed
  • #52: CSS authoring frameworks like Compass and preprocessors like SASS and LESS can make life for the frontend dev a lot easier They are also a great way to get your head into Object Oriented CSS (the SCSS syntax is closer to normal CSS so I recommend using that) Variables, mixins, nesting etc can formalise the whole Object Oriented approach Compass Generating vendor prefixes for you is particularly handy!
  • #53: But for those that aren’t ready to make the move to a new way of authoring CSS, the principles I have been discussing will work right now.
  • #54: Firebug is generated CSS You have to trace back through to the SASS to fix
  • #55: Not only is SASS another layer to debug if something isn’t working properly (particularly for cross-browser testing) It can also make things nasty with nested selectors and overrides – the very things OOCSS is trying to avoid.
  • #57: Also CSS preprocessors shouldn’t just be used to facilitate a new type of lazy coding. I have seen some generated CSS files three times the size of hand-coded ones – that’s over 110Kb or 5,000 lines for a file that could be 35Kb/1,700 lines or so.