SlideShare a Scribd company logo
BBEEMM MMEETTHHOODDOOLLOOGGYY
WHO AM I? 
ANDREW ROTA 
Interactive Developer at Sapient Global Markets 
I build HTML5 / JavaScript web applications 
I was a philosophy major 
I'm an avid sea kayaker
WHAT IS BEM? 
Block 
Element 
Modifier 
History 
tl;dr: Developed by Yandex, Russia's largest search engine 
company, in 2006/2007 to bring structure to web pages. 
Source: BEM
Bem methodology
DDIISSOORRGGAANNIIZZEEDD 
Image by Source: davidd (CC BY 2.0
OOVVEERR SSPPEECCIIFFIICC
LLOOCCAATTIIOONN DDEEPPEENNDDEENNTT 
Image by Source: Guma89 (CC BY-SA 3.0)
ECOSYSTEM 
OOCSS 
.media {margin:10px;} 
.media, .bd {overflow:hidden; _overflow:visible; zoom:1;} 
.media .img {float:left; margin-right: 10px;} 
SMACSS 
.pod-callout { width: 200px; } 
.pod-callout input[type=text] { width: 180px; } 
Atomic CSS 
.M-1 {margin: 1px;} 
.M-2 {margin: 2px;} 
.M-4 {margin: 4px;}
BLOCK 
block /blɒk/ n : A block is an independent 
entity, a "building block" of an application. A 
block can be either simple or compound 
(containing other blocks). 
Source: BEM
BLOCKS 
Source: BEM
ELEMENT 
el•e•ment /ˈɛləmənt/ n : An element is a part 
of a block that performs a certain function. 
Elements are context-dependent: they only 
make sense in the context of the block they 
belong to. 
Source: BEM
MODIFIER 
mod•i•fi•er /ˈmɒdəˌfaɪər/ n : A modifier is a 
property of a block or an element that alters its 
look or behavior. 
Source: BEM
MODIFIERS 
Source: BEM
BACK TO BLOCKS 
Source: BEM
MMAAPPPPIINNGG TTHHEE UUII
DEMO APP
DEMO APP
CSS PRINCIPLES 
Avoid descendent or other cascading selectors 
Element selectors must not be used 
CSS ID selectors must not be used
WRITING BLOCKS 
<nav> 
<ul> 
<li><a href="#">Breaking</a></li> 
<li><a href="#">World</a></li> 
<li><a href="#">U.S.</a></li> 
<li><a href="#">Business</a></li> 
<li><a href="#">Politics</a></li> 
<li><a href="#">Entertainment</a></li> 
<li><a href="#">Technology</a></li> 
<li><a href="#">Sports</a></li> 
</ul> 
</nav>
WRITING BLOCKS 
<nav class="nav-menu"> 
<ul> 
<li><a href="#">Breaking</a></li> 
<li><a href="#">World</a></li> 
<li><a href="#">U.S.</a></li> 
<li><a href="#">Business</a></li> 
<li><a href="#">Politics</a></li> 
<li><a href="#">Entertainment</a></li> 
<li><a href="#">Technology</a></li> 
<li><a href="#">Sports</a></li> 
</ul> 
</nav>
WRITING BLOCKS 
<nav class="nav-menu"> 
<ul class="nav-menu--items"> 
<li class="nav-menu--item"><a href="#">Breaking</a></li> 
<li class="nav-menu--item"><a href="#">World</a></li> 
<li class="nav-menu--item"><a href="#">U.S.</a></li> 
<li class="nav-menu--item"><a href="#">Business</a></li> 
<li class="nav-menu--item"><a href="#">Politics</a></li> 
<li class="nav-menu--item"><a href="#">Entertainment</a></li> 
<li class="nav-menu--item"><a href="#">Technology</a></li> 
<li class="nav-menu--item"><a href="#">Sports</a></li> 
</ul> 
</nav>
WRITING BLOCKS 
.nav-menu { 
display: block; 
margin: 0; 
padding: 0; 
width: 100%; 
float: right; 
} 
.nav-menu--items { 
margin: 0; 
padding: 0; 
} 
.nav-menu--item { 
float: left; 
list-style-type: none; 
margin-left: 0.5%; 
text-align: center; 
width: 12%; 
& > a { 
background: $primaryColor; 
color: white; 
display: block; 
font-size: .9em; 
line-height: 3.2; 
text-decoration: none; 
&:hover { 
background: $primaryColorLighter; 
-webkit-transform: rotate(10deg); 
transform: rotate(10deg);
DEFINE MODIFIERS 
.nav-menu--item__simple { 
@extend .nav-menu; 
display: inline; 
float: none; 
& > a { 
line-height: 1; 
text-decoration: none; 
} 
&:after { 
content: " | "; 
} 
&:last-child:after { 
content: ""; 
} 
}
BUILDING YOUR APPLICATION 
├── blocks 
│ ├── navMenu 
│ │ ├── navMenu.css 
│ │ ├── navMenuItem.css 
│ ├── logo 
│ │ └── logo.css 
│ ├── header 
│ │ └── header.css 
│ └── search 
│ │ ├── search.css 
│ │ └── search_autocomplete.css
DISADVANTAGES 
Repititive code 
Ugly 
Fighting the platform? 
Classitis
ADVANTAGE: NAMESPACING 
.my-component-name__title 
vs 
.my-component .title
OORRGGAANNIIZZAATTIIOONN 
Image by Stewart (CC BY 2.0)
ADVANTAGE: PROGRAMMATIC CONTROL 
block('navMenu').elem('item').click( ... ); 
block('navMenu').elem('item').setModifier('current'); 
Reference: BEM
ADVANTAGE: SHARED UI LANGUAGE 
There are only two hard things in Computer 
Science: cache invalidation and naming things.
PREPROCESSORS: LESS 
.block_name { 
&__element { 
color: #f00; 
&--modifier { 
font-weight: bold; 
} 
} 
} 
Produces 
.block_name__element { 
color: #f00; 
} .block_name__element--modifier { 
font-weight: bold; 
}
PREPROCESSORS: SASS 
$b: ".block_name"; 
#{$b}__element { 
color: #f00; 
} 
#{$b}__element--modifier { 
font-weight: bold; 
} 
Produces 
.block_name__element { 
color: #f00; 
} .block_name__element--modifier { 
font-weight: bold; 
}
PREPROCESSORS: STYLUS 
.block_name 
&__element 
color: #f00 
&--modifier 
font-weight: bold 
Produces 
.block_name__element { 
color: #f00; 
} .block_name__element--modifier { 
font-weight: bold; 
}
TOOLS AND FRAMEWORKS: BEMHTML 
{ 
block: 'navigation', 
content: [ 
{ 
elem: 'item', 
content: 'News' 
} 
] 
}
TOOLS AND FRAMEWORKS: CSSO 
.primary-navigation { 
font-size: 12px; 
color: red; 
font-weight: bold; 
} 
.secondary-navigation { 
color: red; 
font-weight: bold; 
} 
To... 
.primary-navigation{ 
font-size:12px 
} .primary-navigation, .secondary-navigation{ 
color:red; 
font-weight:bold 
}
TOOLS AND FRAMEWORKS: EMMET 
Rather than writing 
ul.primary-navigation>li.primary-navigation__item*5 
Instead write: 
ul.primary-navigation>li.-item*5|bem 
Results in: 
<ul class="primary-navigation"> 
<li class="primary-navigation__item"></li> 
<li class="primary-navigation__item"></li> 
<li class="primary-navigation__item"></li> 
<li class="primary-navigation__item"></li> 
<li class="primary-navigation__item"></li> 
</ul>
TOOLS AND FRAMEWORKS: INUIT.CSS 
Example: 
.pagination { 
text-align:center; 
letter-spacing:-0.31em; 
word-spacing:-0.43em; 
} [...] 
.pagination__first a:before { 
content:"00AB" "00A0"; 
} .pagination__last a:after { 
content:"00A0" "00BB"; 
}
THE FUTURE (?) 
mm/dd/yyyy 
Image by Sam Howzit (CC BY 2.0)

More Related Content

PDF
The benefits of BEM CSS
PDF
BEM - CSS, Seriously
PDF
CSS INHERITANCE
PPTX
Sightly - Part 2
PPT
An Introduction to CSS Preprocessors (SASS & LESS)
PDF
Efficient, maintainable CSS
PDF
Using hilt in a modularized project
The benefits of BEM CSS
BEM - CSS, Seriously
CSS INHERITANCE
Sightly - Part 2
An Introduction to CSS Preprocessors (SASS & LESS)
Efficient, maintainable CSS
Using hilt in a modularized project

What's hot (20)

PDF
Micronaut For Single Page Apps
PDF
CSS3 Media Queries
PPT
CSS
PDF
CSS - OOCSS, SMACSS and more
PPTX
Presentation about html5 css3
PDF
HTML5: features with examples
PPTX
Lab #2: Introduction to Javascript
PDF
CSS For Backend Developers
PDF
Professional Css
PDF
Basic JavaScript Tutorial
PDF
CSS selectors
PDF
Web 2 | CSS - Cascading Style Sheets
PDF
Maintainable CSS
PPTX
Html n CSS
PDF
TUTORIAL DE CSS 2.0
PPT
Span and Div tags in HTML
PPTX
Media queries A to Z
PDF
CSS Dasar #8 : Pseudo-class
PDF
BEM it! Introduction to BEM
Micronaut For Single Page Apps
CSS3 Media Queries
CSS
CSS - OOCSS, SMACSS and more
Presentation about html5 css3
HTML5: features with examples
Lab #2: Introduction to Javascript
CSS For Backend Developers
Professional Css
Basic JavaScript Tutorial
CSS selectors
Web 2 | CSS - Cascading Style Sheets
Maintainable CSS
Html n CSS
TUTORIAL DE CSS 2.0
Span and Div tags in HTML
Media queries A to Z
CSS Dasar #8 : Pseudo-class
BEM it! Introduction to BEM
Ad

Viewers also liked (20)

PPTX
X ray detector
PPTX
Antena array
PPTX
Μάγια Ζαχαρίας
PPTX
Καβάφης Κωνσταντίνος
PPS
Οδός στρατηγού μακρυγιάννη
PPTX
Το μεσαιωνικό κάστρο λεμεσού
PPT
Οι διδυμοι πυργοι της Λεμεσου
PPTX
Καβάφης Κωνσταντίνος
PPTX
ΟΔΟΣ ΑΡΧΙΕΠΙΣΚΟΠΟΥ ΚΥΠΡΟΥ ΛΕΟΝΤΙΟΥ Α΄
PPTX
RENNIE COWAN PHOTOGRAPHY
DOC
Hafil krk 2013
PDF
RENNIE COWAN - COMMERCIAL REEL
PPTX
Οδός Χρυσανθου Επισκόπου Πάφου
PPTX
RENNIE COWAN - ART PIECES
PDF
Portugal x Brasil- No mercado de transferências de jogadores
ODP
Conventions of short films
DOCX
ODP
Short film festivals
PPTX
Pecha Kucha -Ellie- ASSESSMENT 1 (Ophir/Lower Lewis Ponds Creek)
PPTX
Καβάφης Κωνσταντίνος
X ray detector
Antena array
Μάγια Ζαχαρίας
Καβάφης Κωνσταντίνος
Οδός στρατηγού μακρυγιάννη
Το μεσαιωνικό κάστρο λεμεσού
Οι διδυμοι πυργοι της Λεμεσου
Καβάφης Κωνσταντίνος
ΟΔΟΣ ΑΡΧΙΕΠΙΣΚΟΠΟΥ ΚΥΠΡΟΥ ΛΕΟΝΤΙΟΥ Α΄
RENNIE COWAN PHOTOGRAPHY
Hafil krk 2013
RENNIE COWAN - COMMERCIAL REEL
Οδός Χρυσανθου Επισκόπου Πάφου
RENNIE COWAN - ART PIECES
Portugal x Brasil- No mercado de transferências de jogadores
Conventions of short films
Short film festivals
Pecha Kucha -Ellie- ASSESSMENT 1 (Ophir/Lower Lewis Ponds Creek)
Καβάφης Κωνσταντίνος
Ad

Similar to Bem methodology (20)

PDF
The Thinking behind BEM
PPT
Building Web Hack Interfaces
PPTX
Create Responsive Website Design with Bootstrap 3
KEY
前端概述
PDF
Web Development for UX Designers
PPTX
Being a tweaker modern web performance techniques
KEY
Slow kinda sucks
DOCX
“Good design is obvious. Great design is transparent.” — How we use Bootstrap...
PDF
Rapid HTML Prototyping with Bootstrap - Chris Griffith
PDF
HTML5 & CSS3 Flag
PDF
HTML5 New and Improved
PPTX
Diazo: Bridging Designers and Programmers
PDF
Now you see me... Adaptive Web Design and Development
PPT
PPT
css.ppt
PPT
HTML Web Devlopment presentation css.ppt
PPTX
Semantic UI Introduction
PDF
Web Projects: From Theory To Practice
KEY
Faster Frontends
PDF
HTML5 and the dawn of rich mobile web applications pt 2
The Thinking behind BEM
Building Web Hack Interfaces
Create Responsive Website Design with Bootstrap 3
前端概述
Web Development for UX Designers
Being a tweaker modern web performance techniques
Slow kinda sucks
“Good design is obvious. Great design is transparent.” — How we use Bootstrap...
Rapid HTML Prototyping with Bootstrap - Chris Griffith
HTML5 & CSS3 Flag
HTML5 New and Improved
Diazo: Bridging Designers and Programmers
Now you see me... Adaptive Web Design and Development
css.ppt
HTML Web Devlopment presentation css.ppt
Semantic UI Introduction
Web Projects: From Theory To Practice
Faster Frontends
HTML5 and the dawn of rich mobile web applications pt 2

More from Andrew Rota (18)

PDF
Integrating React.js Into a PHP Application: Dutch PHP 2019
PDF
Performant APIs with GraphQL and PHP (Dutch PHP 2019)
PDF
Getting Started with GraphQL && PHP
PDF
Tutorial: Building a GraphQL API in PHP
PPTX
Building a GraphQL API in PHP
PDF
Ten practical ways to improve front-end performance
PDF
Component Based UI Architectures for the Web
PDF
Client-Side Performance Monitoring (MobileTea, Rome)
PDF
Integrating React.js Into a PHP Application
PDF
Effectively Monitoring Client-Side Performance
PDF
UI Rendering at Wayfair
PDF
Better PHP-Frontend Integration with Tungsten.js
PDF
Tungsten.js: Building a Modular Framework
PDF
Why Static Type Checking is Better
PDF
An Exploration of Frameworks – and Why We Built Our Own
PDF
The Complementarity of React and Web Components
PDF
Web Components + Backbone: a Game-Changing Combination
PDF
Web Components and Modular CSS
Integrating React.js Into a PHP Application: Dutch PHP 2019
Performant APIs with GraphQL and PHP (Dutch PHP 2019)
Getting Started with GraphQL && PHP
Tutorial: Building a GraphQL API in PHP
Building a GraphQL API in PHP
Ten practical ways to improve front-end performance
Component Based UI Architectures for the Web
Client-Side Performance Monitoring (MobileTea, Rome)
Integrating React.js Into a PHP Application
Effectively Monitoring Client-Side Performance
UI Rendering at Wayfair
Better PHP-Frontend Integration with Tungsten.js
Tungsten.js: Building a Modular Framework
Why Static Type Checking is Better
An Exploration of Frameworks – and Why We Built Our Own
The Complementarity of React and Web Components
Web Components + Backbone: a Game-Changing Combination
Web Components and Modular CSS

Recently uploaded (20)

PDF
NewMind AI Weekly Chronicles - August'25-Week II
PDF
gpt5_lecture_notes_comprehensive_20250812015547.pdf
PDF
Video forgery: An extensive analysis of inter-and intra-frame manipulation al...
PDF
Univ-Connecticut-ChatGPT-Presentaion.pdf
PDF
Zenith AI: Advanced Artificial Intelligence
PDF
project resource management chapter-09.pdf
PDF
Transform Your ITIL® 4 & ITSM Strategy with AI in 2025.pdf
PDF
A comparative study of natural language inference in Swahili using monolingua...
PDF
A comparative analysis of optical character recognition models for extracting...
PDF
Getting Started with Data Integration: FME Form 101
PPTX
A Presentation on Touch Screen Technology
PDF
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
PDF
Microsoft Solutions Partner Drive Digital Transformation with D365.pdf
PPTX
TechTalks-8-2019-Service-Management-ITIL-Refresh-ITIL-4-Framework-Supports-Ou...
PDF
Heart disease approach using modified random forest and particle swarm optimi...
PPTX
Programs and apps: productivity, graphics, security and other tools
PDF
Assigned Numbers - 2025 - Bluetooth® Document
PDF
DASA ADMISSION 2024_FirstRound_FirstRank_LastRank.pdf
PPTX
Tartificialntelligence_presentation.pptx
PDF
DP Operators-handbook-extract for the Mautical Institute
NewMind AI Weekly Chronicles - August'25-Week II
gpt5_lecture_notes_comprehensive_20250812015547.pdf
Video forgery: An extensive analysis of inter-and intra-frame manipulation al...
Univ-Connecticut-ChatGPT-Presentaion.pdf
Zenith AI: Advanced Artificial Intelligence
project resource management chapter-09.pdf
Transform Your ITIL® 4 & ITSM Strategy with AI in 2025.pdf
A comparative study of natural language inference in Swahili using monolingua...
A comparative analysis of optical character recognition models for extracting...
Getting Started with Data Integration: FME Form 101
A Presentation on Touch Screen Technology
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
Microsoft Solutions Partner Drive Digital Transformation with D365.pdf
TechTalks-8-2019-Service-Management-ITIL-Refresh-ITIL-4-Framework-Supports-Ou...
Heart disease approach using modified random forest and particle swarm optimi...
Programs and apps: productivity, graphics, security and other tools
Assigned Numbers - 2025 - Bluetooth® Document
DASA ADMISSION 2024_FirstRound_FirstRank_LastRank.pdf
Tartificialntelligence_presentation.pptx
DP Operators-handbook-extract for the Mautical Institute

Bem methodology

  • 2. WHO AM I? ANDREW ROTA Interactive Developer at Sapient Global Markets I build HTML5 / JavaScript web applications I was a philosophy major I'm an avid sea kayaker
  • 3. WHAT IS BEM? Block Element Modifier History tl;dr: Developed by Yandex, Russia's largest search engine company, in 2006/2007 to bring structure to web pages. Source: BEM
  • 5. DDIISSOORRGGAANNIIZZEEDD Image by Source: davidd (CC BY 2.0
  • 7. LLOOCCAATTIIOONN DDEEPPEENNDDEENNTT Image by Source: Guma89 (CC BY-SA 3.0)
  • 8. ECOSYSTEM OOCSS .media {margin:10px;} .media, .bd {overflow:hidden; _overflow:visible; zoom:1;} .media .img {float:left; margin-right: 10px;} SMACSS .pod-callout { width: 200px; } .pod-callout input[type=text] { width: 180px; } Atomic CSS .M-1 {margin: 1px;} .M-2 {margin: 2px;} .M-4 {margin: 4px;}
  • 9. BLOCK block /blɒk/ n : A block is an independent entity, a "building block" of an application. A block can be either simple or compound (containing other blocks). Source: BEM
  • 11. ELEMENT el•e•ment /ˈɛləmənt/ n : An element is a part of a block that performs a certain function. Elements are context-dependent: they only make sense in the context of the block they belong to. Source: BEM
  • 12. MODIFIER mod•i•fi•er /ˈmɒdəˌfaɪər/ n : A modifier is a property of a block or an element that alters its look or behavior. Source: BEM
  • 14. BACK TO BLOCKS Source: BEM
  • 18. CSS PRINCIPLES Avoid descendent or other cascading selectors Element selectors must not be used CSS ID selectors must not be used
  • 19. WRITING BLOCKS <nav> <ul> <li><a href="#">Breaking</a></li> <li><a href="#">World</a></li> <li><a href="#">U.S.</a></li> <li><a href="#">Business</a></li> <li><a href="#">Politics</a></li> <li><a href="#">Entertainment</a></li> <li><a href="#">Technology</a></li> <li><a href="#">Sports</a></li> </ul> </nav>
  • 20. WRITING BLOCKS <nav class="nav-menu"> <ul> <li><a href="#">Breaking</a></li> <li><a href="#">World</a></li> <li><a href="#">U.S.</a></li> <li><a href="#">Business</a></li> <li><a href="#">Politics</a></li> <li><a href="#">Entertainment</a></li> <li><a href="#">Technology</a></li> <li><a href="#">Sports</a></li> </ul> </nav>
  • 21. WRITING BLOCKS <nav class="nav-menu"> <ul class="nav-menu--items"> <li class="nav-menu--item"><a href="#">Breaking</a></li> <li class="nav-menu--item"><a href="#">World</a></li> <li class="nav-menu--item"><a href="#">U.S.</a></li> <li class="nav-menu--item"><a href="#">Business</a></li> <li class="nav-menu--item"><a href="#">Politics</a></li> <li class="nav-menu--item"><a href="#">Entertainment</a></li> <li class="nav-menu--item"><a href="#">Technology</a></li> <li class="nav-menu--item"><a href="#">Sports</a></li> </ul> </nav>
  • 22. WRITING BLOCKS .nav-menu { display: block; margin: 0; padding: 0; width: 100%; float: right; } .nav-menu--items { margin: 0; padding: 0; } .nav-menu--item { float: left; list-style-type: none; margin-left: 0.5%; text-align: center; width: 12%; & > a { background: $primaryColor; color: white; display: block; font-size: .9em; line-height: 3.2; text-decoration: none; &:hover { background: $primaryColorLighter; -webkit-transform: rotate(10deg); transform: rotate(10deg);
  • 23. DEFINE MODIFIERS .nav-menu--item__simple { @extend .nav-menu; display: inline; float: none; & > a { line-height: 1; text-decoration: none; } &:after { content: " | "; } &:last-child:after { content: ""; } }
  • 24. BUILDING YOUR APPLICATION ├── blocks │ ├── navMenu │ │ ├── navMenu.css │ │ ├── navMenuItem.css │ ├── logo │ │ └── logo.css │ ├── header │ │ └── header.css │ └── search │ │ ├── search.css │ │ └── search_autocomplete.css
  • 25. DISADVANTAGES Repititive code Ugly Fighting the platform? Classitis
  • 27. OORRGGAANNIIZZAATTIIOONN Image by Stewart (CC BY 2.0)
  • 28. ADVANTAGE: PROGRAMMATIC CONTROL block('navMenu').elem('item').click( ... ); block('navMenu').elem('item').setModifier('current'); Reference: BEM
  • 29. ADVANTAGE: SHARED UI LANGUAGE There are only two hard things in Computer Science: cache invalidation and naming things.
  • 30. PREPROCESSORS: LESS .block_name { &__element { color: #f00; &--modifier { font-weight: bold; } } } Produces .block_name__element { color: #f00; } .block_name__element--modifier { font-weight: bold; }
  • 31. PREPROCESSORS: SASS $b: ".block_name"; #{$b}__element { color: #f00; } #{$b}__element--modifier { font-weight: bold; } Produces .block_name__element { color: #f00; } .block_name__element--modifier { font-weight: bold; }
  • 32. PREPROCESSORS: STYLUS .block_name &__element color: #f00 &--modifier font-weight: bold Produces .block_name__element { color: #f00; } .block_name__element--modifier { font-weight: bold; }
  • 33. TOOLS AND FRAMEWORKS: BEMHTML { block: 'navigation', content: [ { elem: 'item', content: 'News' } ] }
  • 34. TOOLS AND FRAMEWORKS: CSSO .primary-navigation { font-size: 12px; color: red; font-weight: bold; } .secondary-navigation { color: red; font-weight: bold; } To... .primary-navigation{ font-size:12px } .primary-navigation, .secondary-navigation{ color:red; font-weight:bold }
  • 35. TOOLS AND FRAMEWORKS: EMMET Rather than writing ul.primary-navigation>li.primary-navigation__item*5 Instead write: ul.primary-navigation>li.-item*5|bem Results in: <ul class="primary-navigation"> <li class="primary-navigation__item"></li> <li class="primary-navigation__item"></li> <li class="primary-navigation__item"></li> <li class="primary-navigation__item"></li> <li class="primary-navigation__item"></li> </ul>
  • 36. TOOLS AND FRAMEWORKS: INUIT.CSS Example: .pagination { text-align:center; letter-spacing:-0.31em; word-spacing:-0.43em; } [...] .pagination__first a:before { content:"00AB" "00A0"; } .pagination__last a:after { content:"00A0" "00BB"; }
  • 37. THE FUTURE (?) mm/dd/yyyy Image by Sam Howzit (CC BY 2.0)