SlideShare a Scribd company logo
BEM it! 
Introduction to BEM Methodology 
by Varya Stepanova 
at SC5 Tuesday Streaming, 21.10.2014
Why bother?
There is no unified semantic model 
across different FE technologies 
● HTML stands for hypertext 
I've heard we mostly do web apps... 
● CSS offers no structure out of the box 
Usually a pile of rules put together. Sorry. 
● JavaScript uses its own approaches. 
...a new one comes with every framework.
Frameworks are not enough 
● ≈ 8,500 packages in Bower registry 
● JavaScript: 
the most popular language on GitHub 
Repositories created: 
≈ 264,000 in 2013 
≈ 296,000 in 2012
BEM to the rescue
What is BEM? 
BEM claims that simple semantic model 
(Blocks, Elements, and Modifiers) 
is enough to define the way you author 
HTML / CSS / JavaScript, structure code 
and components, set up interaction 
and scale your project to build 
an industry-leading service.
What is BEM? 
● BEM is a methodology, not a framework 
Semantic model + best practices 
for all things frontend 
● BEM is a fix for web app semantics 
...the same as jQuery is a fix for DOM APIs 
● Originally introduced by Yandex 
— 19 million daily audience 
— 200+ web services 
— tools, code, tutorials, conferences 
— open source
Some theory
What is BEM? 
BLOCK 
– Standalone part of an interface: 
● button 
● text field 
● flyout 
● heading 
● menu
What is BEM? 
BLOCK 
– Standalone part of an interface: 
● button 
● text field 
● flyout 
● heading 
● menu 
– Re-usable in different contexts 
– Self-sufficient
What is BEM? 
ELEMENT 
– An integral part of a block: 
● button 
● text field 
● flyout 
● heading 
● menu
What is BEM? 
ELEMENT 
– An integral part of a block: 
● button — contains no elements 
● text field label 
● flyout title 
● heading logo 
● menu item
What is BEM? 
ELEMENT 
– An integral part of a block: 
● button — contains no elements 
● text field label 
● flyout title 
● heading logo 
● menu item 
– No standalone meaning outside of a block 
– Some blocks have no elements
What is BEM? 
MODIFIER 
– Defines property or state on a block or element: 
● button 
● text field 
● flyout 
● heading 
● menu item
What is BEM? 
MODIFIER 
– Defines property or state on a block or element: 
● button theme 
● text field editable state 
● flyout alignment 
● heading level 
● menu item bullet type
What is BEM? 
MODIFIER 
– Defines property or state on a block or element: 
● button theme 
● text field editable state 
● flyout alignment 
● heading level 
● menu item bullet type 
– Multiple modifiers may co-exist 
on a single block/element
BEM forms a semantic overlay over 
the existing DOM structure. 
This overlay is called a BEM tree.
DOM tree → BEM tree
How does BEM map to DOM? 
● Blocks/elems/mods are denoted 
with CSS classes using a naming convention. 
● DOM nodes can be shared: 
— block1 + block2 may occupy the same 
container; 
— element1 + block2 may co-exist on 
the same node. 
● DOM is encapsulated: 
— complex DOM structure may constitute 
a single element
BEM HOWTO 
for your beloved project 
with benefits explained
HOWTO: HTML / CSS
CSS naming conventions 
“BEM uses CSS class names to 
denote blocks, elements and 
modifiers.”
CSS naming conventions 
BLOCK 
.button 
.text-field 
.flyout 
.heading 
.menu 
or with prefix 
.b-button 
.b-text-field 
.b-flyout 
.b-heading 
.b-menu
CSS naming conventions 
<ul class=”menu”> 
<li> 
<a href=”/more”>Read More</a> 
</li> 
<li> 
<a href=”/buy”>Buy Online</a> 
</li> 
<li> 
<a href=”/buy”>Contact</a> 
</li> 
</ul>
CSS naming conventions 
ELEMENT 
.button__icon 
.text-field__label 
.flyout__title 
.heading__logo 
.menu__item
CSS naming conventions 
<ul class=”menu”> 
<li class=”menu__item”> 
<a href=”/more”>Read More</a> 
</li> 
<li class=”menu__item”> 
<a href=”/buy”>Buy Online</a> 
</li> 
<li class=”menu__item”> 
<a href=”/buy”>Contact</a> 
</li> 
</ul>
CSS naming conventions 
MODIFIER 
.button_theme_dark 
.text-field_editable 
.flyout_align_top 
.heading_level_alpha 
.menu__item_promo
CSS naming conventions 
MODIFIER 
as you wish 
.button--theme--dark 
.text-field--editable 
.flyout--align--top 
.heading--level--alpha 
.menu__item--promo
CSS naming conventions 
<ul class=”menu”> 
<li class=”menu__item”> 
<a href=”/more”>Read More</a> 
</li> 
<li class=”menu__item”> 
<a href=”/buy”>Buy Online</a> 
</li> 
<li class=”menu__item”> 
<a href=”/buy”>Contact</a> 
</li> 
</ul>
CSS naming conventions 
<ul class=”menu”> 
<li class=”menu__item menu__item_promo”> 
<a href=”/more”>Read More</a> 
</li> 
<li class=”menu__item”> 
<a href=”/buy”>Buy Online</a> 
</li> 
<li class=”menu__item”> 
<a href=”/buy”>Contact</a> 
</li> 
</ul>
so structure 
much much semantics 
wow 
very code 
such frontend
BEM CSS: best practices 
1. Map the whole document to BEM blocks 
2. No CSS outside of blocks 
3. Independent blocks → no global CSS resets
Benefits! 
Drop tag names and IDs 
● Faster selectors 
● Re-use same semantics on any tag: 
— <DIV class=”block”> 
— <SPAN class=”block”> 
— <TABLE class=”block”>
Benefits! 
Bye-bye CSS cascade?! 
Only one CSS class needed to: 
● style a block container 
● style any element within a block 
● add extras/overrides with a modifier 
Doesn't it cover 90% of your styling needs?
Benefits! 
CSS specificity magic solved 
Priority of CSS rules: 
by specificity first, then by rule order 
td.data { background-color: gray } 
td.summary { background-color: white } 
.total-summary { background-color: yellow } 
<TD class="summary total-summary"> 
<!-- Still gray, baby :-( --> 
</TD>
Benefits! 
CSS specificity magic solved 
Priority of CSS rules: 
by specificity first, then by rule order 
td.data { background-color: gray } 
td.summary { background-color: white } 
td.total-summary { background-color: yellow } 
<TD class="summary total-summary"> 
<!-- This works, I'm yellow now --> 
</TD>
Benefits! 
Bye-bye CSS cascade?! 
...well, not exactly. 
Example of an element affected by a block modifier: 
/* theme menu items for a dark theme */ 
.menu_theme_dark .menu__item 
{ 
color: white; 
background-color: darkgray; 
}
HOWTO: 
Block dependencies
Download Help Contact 
password LLooggiinn 
Main 
username
mmeennuu 
Download Help Contact 
password LLooggiinn 
Main 
username 
hheeaaddeerr 
tteexxtt iinnppuutt tteexxtt iinnppuutt bbuuttttoonn
Download Help Contact 
_size_small _size_small _primary 
password LLooggiinn 
Main 
username
Download Help Contact 
password LLooggiinn 
Main 
username 
.header .input { font-size: 0.85em } 
.header .button { background: navy }
Download Help Contact 
password LLooggiinn 
Main 
username 
.header .input { font-size: 0.85em } 
.header .button { background: navy } !
HOWTO: JavaScript
JavaScript 
Components → Blocks 
Work with BEM tree, not DOM tree
JavaScript deals with BEM 
blockObj 
blockObj.setMod('active'); 
// <div class=”block block_active”> 
blockObj.delMod('active); 
// <div class=”block”>
JavaScript deals with BEM 
BlockObj.do({ 
'active': function() { 
// do smth when active 
}, 
'disabled': function() { 
// do something when disabled 
} 
});
JavaScript 
i-bem.js framework by Yandex + tutorial 
http://bit.ly/bem-js-tutorial/ 
● First English docs (expect more!) 
● 100% BEM-based declarative API 
● Part of a larger bem-core library
HTML is no longer semantic. 
JavaScript is.
HOWTO: Design / UX
BEM is the universal language 
for developers and designers, 
the bridge across technology 
gaps.
Build your block library. 
The code itself is the styleguide.
UX + Frontend 
● Live style guide 
● Always up-to-date 
● Prototyping mapped to code from 
day one 
● Designers and devs speak the same 
language 
● Good for making early estimates
HOWTO: File structure
File and folder structure 
Flat block structure with a folder for each block. 
Simple structure for BEM beginners: 
/block 
block.css 
block.js 
block.tpl 
...whatever you need
File and folder structure 
Advanced structure to expose semantics 
/block 
/__elem1 
block__elem1.css 
block__elem1.tpl 
/_mod 
block_mod.css 
block.css 
block.js 
block.tpl
Bundles for browsers 
page.css: 
@import url(“header/header.css”); 
@import url(“button/button.css”); 
@import url(“button/button_promo.css”); 
page.js: 
/* include: button.js */ 
/* include: login.js */
Build process and deployment 
Use a build tool! 
Borschik: 
an open-source build tool by Yandex 
Code: 
https://github.com/bem/borschik 
English docs: 
http://bem.info/articles/borschik
Build process and deployment 
Any familiar tool can be a builder 
Gulp: 
Example: 
https://github.com/getbem/getbem.com
BEM gives answers to: 
1. Where is code for this interface object? 
●CSS 
● JS 
●Templates 
●Documentation 
2.Can I remove this piece of code? 
3.How do I name this new item?
http://bem.info 
http://getbem.com
Thank you SC5! 
@varya_en 
http://varya.me

More Related Content

What's hot

What is Object Oriented CSS?
What is Object Oriented CSS?What is Object Oriented CSS?
What is Object Oriented CSS?
Nicole Sullivan
 
Bliblidotcom - Reintroduction BEM CSS
Bliblidotcom - Reintroduction BEM CSSBliblidotcom - Reintroduction BEM CSS
Bliblidotcom - Reintroduction BEM CSS
Irfan Maulana
 
How to manage a big scale HTML/CSS project
How to manage a big scale HTML/CSS projectHow to manage a big scale HTML/CSS project
How to manage a big scale HTML/CSS projectRenoir Boulanger
 
CSS3 Media Queries
CSS3 Media QueriesCSS3 Media Queries
CSS3 Media Queries
Russ Weakley
 
CSS Best practice
CSS Best practiceCSS Best practice
CSS Best practice
Russ Weakley
 
Responsive web-design through bootstrap
Responsive web-design through bootstrapResponsive web-design through bootstrap
Responsive web-design through bootstrap
Zunair Sagitarioux
 
CSS Grid vs. Flexbox
CSS Grid vs. FlexboxCSS Grid vs. Flexbox
CSS Grid vs. Flexbox
Ecaterina Moraru (Valica)
 
HTML/CSS Crash Course (april 4 2017)
HTML/CSS Crash Course (april 4 2017)HTML/CSS Crash Course (april 4 2017)
HTML/CSS Crash Course (april 4 2017)
Daniel Friedman
 
Introduction to CSS3
Introduction to CSS3Introduction to CSS3
Introduction to CSS3
Doris Chen
 
CSS Grid
CSS GridCSS Grid
Learn BEM: CSS Naming Convention
Learn BEM: CSS Naming ConventionLearn BEM: CSS Naming Convention
Learn BEM: CSS Naming Convention
In a Rocket
 
Object Oriented CSS
Object Oriented CSSObject Oriented CSS
Object Oriented CSS
Nicole Sullivan
 
DRY CSS A don’t-repeat-yourself methodology for creating efficient, unified a...
DRY CSS A don’t-repeat-yourself methodology for creating efficient, unified a...DRY CSS A don’t-repeat-yourself methodology for creating efficient, unified a...
DRY CSS A don’t-repeat-yourself methodology for creating efficient, unified a...
Jer Clarke
 
Introduction to SASS
Introduction to SASSIntroduction to SASS
Introduction to SASSJon Dean
 
HTML5 Essentials
HTML5 EssentialsHTML5 Essentials
HTML5 Essentials
Marc Grabanski
 
HTML and CSS crash course!
HTML and CSS crash course!HTML and CSS crash course!
HTML and CSS crash course!
Ana Cidre
 
An Introduction to CSS Preprocessors (SASS & LESS)
An Introduction to CSS Preprocessors (SASS & LESS)An Introduction to CSS Preprocessors (SASS & LESS)
An Introduction to CSS Preprocessors (SASS & LESS)
Folio3 Software
 
Bootstrap 3
Bootstrap 3Bootstrap 3
Bootstrap 3
McSoftsis
 
Flexbox and Grid Layout
Flexbox and Grid LayoutFlexbox and Grid Layout
Flexbox and Grid Layout
Rachel Andrew
 
Advanced Cascading Style Sheets
Advanced Cascading Style SheetsAdvanced Cascading Style Sheets
Advanced Cascading Style Sheets
fantasticdigitaltools
 

What's hot (20)

What is Object Oriented CSS?
What is Object Oriented CSS?What is Object Oriented CSS?
What is Object Oriented CSS?
 
Bliblidotcom - Reintroduction BEM CSS
Bliblidotcom - Reintroduction BEM CSSBliblidotcom - Reintroduction BEM CSS
Bliblidotcom - Reintroduction BEM CSS
 
How to manage a big scale HTML/CSS project
How to manage a big scale HTML/CSS projectHow to manage a big scale HTML/CSS project
How to manage a big scale HTML/CSS project
 
CSS3 Media Queries
CSS3 Media QueriesCSS3 Media Queries
CSS3 Media Queries
 
CSS Best practice
CSS Best practiceCSS Best practice
CSS Best practice
 
Responsive web-design through bootstrap
Responsive web-design through bootstrapResponsive web-design through bootstrap
Responsive web-design through bootstrap
 
CSS Grid vs. Flexbox
CSS Grid vs. FlexboxCSS Grid vs. Flexbox
CSS Grid vs. Flexbox
 
HTML/CSS Crash Course (april 4 2017)
HTML/CSS Crash Course (april 4 2017)HTML/CSS Crash Course (april 4 2017)
HTML/CSS Crash Course (april 4 2017)
 
Introduction to CSS3
Introduction to CSS3Introduction to CSS3
Introduction to CSS3
 
CSS Grid
CSS GridCSS Grid
CSS Grid
 
Learn BEM: CSS Naming Convention
Learn BEM: CSS Naming ConventionLearn BEM: CSS Naming Convention
Learn BEM: CSS Naming Convention
 
Object Oriented CSS
Object Oriented CSSObject Oriented CSS
Object Oriented CSS
 
DRY CSS A don’t-repeat-yourself methodology for creating efficient, unified a...
DRY CSS A don’t-repeat-yourself methodology for creating efficient, unified a...DRY CSS A don’t-repeat-yourself methodology for creating efficient, unified a...
DRY CSS A don’t-repeat-yourself methodology for creating efficient, unified a...
 
Introduction to SASS
Introduction to SASSIntroduction to SASS
Introduction to SASS
 
HTML5 Essentials
HTML5 EssentialsHTML5 Essentials
HTML5 Essentials
 
HTML and CSS crash course!
HTML and CSS crash course!HTML and CSS crash course!
HTML and CSS crash course!
 
An Introduction to CSS Preprocessors (SASS & LESS)
An Introduction to CSS Preprocessors (SASS & LESS)An Introduction to CSS Preprocessors (SASS & LESS)
An Introduction to CSS Preprocessors (SASS & LESS)
 
Bootstrap 3
Bootstrap 3Bootstrap 3
Bootstrap 3
 
Flexbox and Grid Layout
Flexbox and Grid LayoutFlexbox and Grid Layout
Flexbox and Grid Layout
 
Advanced Cascading Style Sheets
Advanced Cascading Style SheetsAdvanced Cascading Style Sheets
Advanced Cascading Style Sheets
 

Viewers also liked

Instrukacja montazu-listwy-sztywne-orac
Instrukacja montazu-listwy-sztywne-oracInstrukacja montazu-listwy-sztywne-orac
Instrukacja montazu-listwy-sztywne-oracskleporac
 
Session 2 - Q&A
Session 2 - Q&ASession 2 - Q&A
Session 2 - Q&A
The Digital Insurer
 
Du vil vel ikke mamma noe vondt?
Du vil vel ikke mamma noe vondt?Du vil vel ikke mamma noe vondt?
Du vil vel ikke mamma noe vondt?
FINN.no
 
Who am I?
Who am I?Who am I?
Who am I?
cblockus
 
An approach for managing and semantically enriching the publication of Linked...
An approach for managing and semantically enriching the publication of Linked...An approach for managing and semantically enriching the publication of Linked...
An approach for managing and semantically enriching the publication of Linked...
greco_ufrj
 
Pemanfaatan ekstrak serai(sitronela) sebagai pengusir nyamuk
Pemanfaatan ekstrak serai(sitronela) sebagai pengusir nyamukPemanfaatan ekstrak serai(sitronela) sebagai pengusir nyamuk
Pemanfaatan ekstrak serai(sitronela) sebagai pengusir nyamuk
Muhammad Syahida
 
DOC3 - Soft Drinks and Beer 4 MI
DOC3 - Soft Drinks and Beer 4 MIDOC3 - Soft Drinks and Beer 4 MI
DOC3 - Soft Drinks and Beer 4 MI
ToxiColaOrg
 
Dia-logic
Dia-logicDia-logic
Dia-logic
victor kintanar
 
Presentation final
Presentation finalPresentation final
Presentation finallyonka02
 
UCE ESCUELA DE IDIOMAS "PREPOSITIONS OF PLACE" KEVIN QUEVEDO
UCE ESCUELA DE IDIOMAS "PREPOSITIONS OF PLACE" KEVIN QUEVEDO UCE ESCUELA DE IDIOMAS "PREPOSITIONS OF PLACE" KEVIN QUEVEDO
UCE ESCUELA DE IDIOMAS "PREPOSITIONS OF PLACE" KEVIN QUEVEDO
kevin Quevedo
 
Horario Escolar - Profesores de Computo
Horario Escolar - Profesores de ComputoHorario Escolar - Profesores de Computo
Horario Escolar - Profesores de Computo
Medardo Aparcana
 
3 examen et corrige arabe 2014 1 am t1
3 examen et corrige arabe 2014 1 am t13 examen et corrige arabe 2014 1 am t1
3 examen et corrige arabe 2014 1 am t1
Ahmed Mesellem
 
1 examen et corrige edu civ 2014 1-am t1
1 examen et corrige edu civ 2014 1-am t11 examen et corrige edu civ 2014 1-am t1
1 examen et corrige edu civ 2014 1-am t1Ahmed Mesellem
 
A3 examen et corrige francais 2011 1 am t2
A3 examen et corrige francais 2011 1 am t2A3 examen et corrige francais 2011 1 am t2
A3 examen et corrige francais 2011 1 am t2
Ahmed Mesellem
 
A4 examen et corrige arabe 2013 1 am t2
A4 examen et corrige arabe 2013 1 am t2A4 examen et corrige arabe 2013 1 am t2
A4 examen et corrige arabe 2013 1 am t2Ahmed Mesellem
 

Viewers also liked (20)

Instrukacja montazu-listwy-sztywne-orac
Instrukacja montazu-listwy-sztywne-oracInstrukacja montazu-listwy-sztywne-orac
Instrukacja montazu-listwy-sztywne-orac
 
Session 2 - Q&A
Session 2 - Q&ASession 2 - Q&A
Session 2 - Q&A
 
Du vil vel ikke mamma noe vondt?
Du vil vel ikke mamma noe vondt?Du vil vel ikke mamma noe vondt?
Du vil vel ikke mamma noe vondt?
 
Tic
TicTic
Tic
 
Presa itog 3
Presa itog 3Presa itog 3
Presa itog 3
 
Who am I?
Who am I?Who am I?
Who am I?
 
Dr. death
Dr. deathDr. death
Dr. death
 
Podstawy projektowania do Internetu - zdjęcia
Podstawy projektowania do Internetu - zdjęciaPodstawy projektowania do Internetu - zdjęcia
Podstawy projektowania do Internetu - zdjęcia
 
An approach for managing and semantically enriching the publication of Linked...
An approach for managing and semantically enriching the publication of Linked...An approach for managing and semantically enriching the publication of Linked...
An approach for managing and semantically enriching the publication of Linked...
 
Pemanfaatan ekstrak serai(sitronela) sebagai pengusir nyamuk
Pemanfaatan ekstrak serai(sitronela) sebagai pengusir nyamukPemanfaatan ekstrak serai(sitronela) sebagai pengusir nyamuk
Pemanfaatan ekstrak serai(sitronela) sebagai pengusir nyamuk
 
DOC3 - Soft Drinks and Beer 4 MI
DOC3 - Soft Drinks and Beer 4 MIDOC3 - Soft Drinks and Beer 4 MI
DOC3 - Soft Drinks and Beer 4 MI
 
Dia-logic
Dia-logicDia-logic
Dia-logic
 
Presentation final
Presentation finalPresentation final
Presentation final
 
UCE ESCUELA DE IDIOMAS "PREPOSITIONS OF PLACE" KEVIN QUEVEDO
UCE ESCUELA DE IDIOMAS "PREPOSITIONS OF PLACE" KEVIN QUEVEDO UCE ESCUELA DE IDIOMAS "PREPOSITIONS OF PLACE" KEVIN QUEVEDO
UCE ESCUELA DE IDIOMAS "PREPOSITIONS OF PLACE" KEVIN QUEVEDO
 
Horario Escolar - Profesores de Computo
Horario Escolar - Profesores de ComputoHorario Escolar - Profesores de Computo
Horario Escolar - Profesores de Computo
 
3 examen et corrige arabe 2014 1 am t1
3 examen et corrige arabe 2014 1 am t13 examen et corrige arabe 2014 1 am t1
3 examen et corrige arabe 2014 1 am t1
 
1 examen et corrige edu civ 2014 1-am t1
1 examen et corrige edu civ 2014 1-am t11 examen et corrige edu civ 2014 1-am t1
1 examen et corrige edu civ 2014 1-am t1
 
A3 examen et corrige francais 2011 1 am t2
A3 examen et corrige francais 2011 1 am t2A3 examen et corrige francais 2011 1 am t2
A3 examen et corrige francais 2011 1 am t2
 
A4 examen et corrige arabe 2013 1 am t2
A4 examen et corrige arabe 2013 1 am t2A4 examen et corrige arabe 2013 1 am t2
A4 examen et corrige arabe 2013 1 am t2
 
Binder1
Binder1Binder1
Binder1
 

Similar to BEM it! Introduction to BEM

BEM it!
BEM it!BEM it!
BEM it!
Max Shirshin
 
BEM methodology overview
BEM methodology overviewBEM methodology overview
BEM methodology overview
Oleksii Prohonnyi
 
Fewd week2 slides
Fewd week2 slidesFewd week2 slides
Fewd week2 slides
William Myers
 
Build and save your own Gutenberg Block Patterns
Build and save your own Gutenberg Block PatternsBuild and save your own Gutenberg Block Patterns
Build and save your own Gutenberg Block Patterns
Plasterdog Web Design
 
BEM it!
BEM it!BEM it!
HTML and CSS Coding Standards
HTML and CSS Coding StandardsHTML and CSS Coding Standards
HTML and CSS Coding Standards
Saajan Maharjan
 
Blog It Up, Baby! Extending the new IBM Lotus Domino Blog Template
Blog It Up, Baby! Extending the new IBM Lotus Domino Blog TemplateBlog It Up, Baby! Extending the new IBM Lotus Domino Blog Template
Blog It Up, Baby! Extending the new IBM Lotus Domino Blog Template
Sean Burgess
 
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
Sanjoy Kr. Paul
 
Teams, styles and scalable applications
Teams, styles and scalable applicationsTeams, styles and scalable applications
Teams, styles and scalable applications
Vittorio Vittori
 
Highly Maintainable, Efficient, and Optimized CSS
Highly Maintainable, Efficient, and Optimized CSSHighly Maintainable, Efficient, and Optimized CSS
Highly Maintainable, Efficient, and Optimized CSSZoe Gillenwater
 
Joomla! Day UK 2009 Basic Templates
Joomla! Day UK 2009 Basic TemplatesJoomla! Day UK 2009 Basic Templates
Joomla! Day UK 2009 Basic Templates
Andy Wallace
 
Joomla Day UK 2009 Basic Templates
Joomla Day UK 2009 Basic TemplatesJoomla Day UK 2009 Basic Templates
Joomla Day UK 2009 Basic Templates
Chris Davenport
 
Html.ppt
Html.pptHtml.ppt
Html.ppt
oleksandro
 
Making Your Site Look Great in IE7
Making Your Site Look Great in IE7Making Your Site Look Great in IE7
Making Your Site Look Great in IE7
goodfriday
 
Flatsome | Responsive WooCommerce Theme - WordPress
Flatsome | Responsive WooCommerce Theme - WordPressFlatsome | Responsive WooCommerce Theme - WordPress
Flatsome | Responsive WooCommerce Theme - WordPress
sharpgwxtzxgccc
 
Magento - Design Integration Guideline - Bysoft China
Magento - Design Integration Guideline - Bysoft ChinaMagento - Design Integration Guideline - Bysoft China
Magento - Design Integration Guideline - Bysoft China
Bysoft Technologies
 
Pfnp slides
Pfnp slidesPfnp slides
Pfnp slides
William Myers
 
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
Deepu S Nath
 
Introduction to the Magento eCommerce Platform
Introduction to the Magento eCommerce PlatformIntroduction to the Magento eCommerce Platform
Introduction to the Magento eCommerce Platform
Jarne W. Beutnagel
 

Similar to BEM it! Introduction to BEM (20)

BEM it!
BEM it!BEM it!
BEM it!
 
BEM methodology overview
BEM methodology overviewBEM methodology overview
BEM methodology overview
 
Fewd week2 slides
Fewd week2 slidesFewd week2 slides
Fewd week2 slides
 
Build and save your own Gutenberg Block Patterns
Build and save your own Gutenberg Block PatternsBuild and save your own Gutenberg Block Patterns
Build and save your own Gutenberg Block Patterns
 
BEM it!
BEM it!BEM it!
BEM it!
 
HTML and CSS Coding Standards
HTML and CSS Coding StandardsHTML and CSS Coding Standards
HTML and CSS Coding Standards
 
Blog It Up, Baby! Extending the new IBM Lotus Domino Blog Template
Blog It Up, Baby! Extending the new IBM Lotus Domino Blog TemplateBlog It Up, Baby! Extending the new IBM Lotus Domino Blog Template
Blog It Up, Baby! Extending the new IBM Lotus Domino Blog Template
 
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
 
Teams, styles and scalable applications
Teams, styles and scalable applicationsTeams, styles and scalable applications
Teams, styles and scalable applications
 
Highly Maintainable, Efficient, and Optimized CSS
Highly Maintainable, Efficient, and Optimized CSSHighly Maintainable, Efficient, and Optimized CSS
Highly Maintainable, Efficient, and Optimized CSS
 
Joomla! Day UK 2009 Basic Templates
Joomla! Day UK 2009 Basic TemplatesJoomla! Day UK 2009 Basic Templates
Joomla! Day UK 2009 Basic Templates
 
Joomla Day UK 2009 Basic Templates
Joomla Day UK 2009 Basic TemplatesJoomla Day UK 2009 Basic Templates
Joomla Day UK 2009 Basic Templates
 
Html.ppt
Html.pptHtml.ppt
Html.ppt
 
Making Your Site Look Great in IE7
Making Your Site Look Great in IE7Making Your Site Look Great in IE7
Making Your Site Look Great in IE7
 
Flatsome | Responsive WooCommerce Theme - WordPress
Flatsome | Responsive WooCommerce Theme - WordPressFlatsome | Responsive WooCommerce Theme - WordPress
Flatsome | Responsive WooCommerce Theme - WordPress
 
Magento - Design Integration Guideline - Bysoft China
Magento - Design Integration Guideline - Bysoft ChinaMagento - Design Integration Guideline - Bysoft China
Magento - Design Integration Guideline - Bysoft China
 
BEM
BEMBEM
BEM
 
Pfnp slides
Pfnp slidesPfnp slides
Pfnp slides
 
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
 
Introduction to the Magento eCommerce Platform
Introduction to the Magento eCommerce PlatformIntroduction to the Magento eCommerce Platform
Introduction to the Magento eCommerce Platform
 

More from Varya Stepanova

Design systems on the web
Design systems on the webDesign systems on the web
Design systems on the web
Varya Stepanova
 
SC5 Style Guide Generator
SC5 Style Guide GeneratorSC5 Style Guide Generator
SC5 Style Guide GeneratorVarya Stepanova
 
Maintainable Frontend Development with BEM
Maintainable Frontend Development with BEMMaintainable Frontend Development with BEM
Maintainable Frontend Development with BEM
Varya Stepanova
 
BEM. What you can borrow from Yandex frontend dev
BEM. What you can borrow from Yandex frontend devBEM. What you can borrow from Yandex frontend dev
BEM. What you can borrow from Yandex frontend dev
Varya Stepanova
 
Тема для WordPress в БЭМ
Тема для WordPress в БЭМТема для WordPress в БЭМ
Тема для WordPress в БЭМ
Varya Stepanova
 
Шаблонизатор BEMHTML
Шаблонизатор BEMHTMLШаблонизатор BEMHTML
Шаблонизатор BEMHTML
Varya Stepanova
 
Использование библиотеки bem-bl
Использование библиотеки bem-blИспользование библиотеки bem-bl
Использование библиотеки bem-bl
Varya Stepanova
 
JavaScript в БЭМ терминах
JavaScript в БЭМ терминахJavaScript в БЭМ терминах
JavaScript в БЭМ терминах
Varya Stepanova
 
Использование библиотеки bem-bl
Использование библиотеки bem-blИспользование библиотеки bem-bl
Использование библиотеки bem-bl
Varya Stepanova
 

More from Varya Stepanova (11)

Design systems on the web
Design systems on the webDesign systems on the web
Design systems on the web
 
SC5 Style Guide Generator
SC5 Style Guide GeneratorSC5 Style Guide Generator
SC5 Style Guide Generator
 
The Thinking behind BEM
The Thinking behind BEMThe Thinking behind BEM
The Thinking behind BEM
 
Modular development
Modular developmentModular development
Modular development
 
Maintainable Frontend Development with BEM
Maintainable Frontend Development with BEMMaintainable Frontend Development with BEM
Maintainable Frontend Development with BEM
 
BEM. What you can borrow from Yandex frontend dev
BEM. What you can borrow from Yandex frontend devBEM. What you can borrow from Yandex frontend dev
BEM. What you can borrow from Yandex frontend dev
 
Тема для WordPress в БЭМ
Тема для WordPress в БЭМТема для WordPress в БЭМ
Тема для WordPress в БЭМ
 
Шаблонизатор BEMHTML
Шаблонизатор BEMHTMLШаблонизатор BEMHTML
Шаблонизатор BEMHTML
 
Использование библиотеки bem-bl
Использование библиотеки bem-blИспользование библиотеки bem-bl
Использование библиотеки bem-bl
 
JavaScript в БЭМ терминах
JavaScript в БЭМ терминахJavaScript в БЭМ терминах
JavaScript в БЭМ терминах
 
Использование библиотеки bem-bl
Использование библиотеки bem-blИспользование библиотеки bem-bl
Использование библиотеки bem-bl
 

Recently uploaded

ACRP 4-09 Risk Assessment Method to Support Modification of Airfield Separat...
ACRP 4-09 Risk Assessment Method to Support Modification of Airfield Separat...ACRP 4-09 Risk Assessment Method to Support Modification of Airfield Separat...
ACRP 4-09 Risk Assessment Method to Support Modification of Airfield Separat...
Mukeshwaran Balu
 
Fundamentals of Electric Drives and its applications.pptx
Fundamentals of Electric Drives and its applications.pptxFundamentals of Electric Drives and its applications.pptx
Fundamentals of Electric Drives and its applications.pptx
manasideore6
 
A review on techniques and modelling methodologies used for checking electrom...
A review on techniques and modelling methodologies used for checking electrom...A review on techniques and modelling methodologies used for checking electrom...
A review on techniques and modelling methodologies used for checking electrom...
nooriasukmaningtyas
 
Series of visio cisco devices Cisco_Icons.ppt
Series of visio cisco devices Cisco_Icons.pptSeries of visio cisco devices Cisco_Icons.ppt
Series of visio cisco devices Cisco_Icons.ppt
PauloRodrigues104553
 
Hierarchical Digital Twin of a Naval Power System
Hierarchical Digital Twin of a Naval Power SystemHierarchical Digital Twin of a Naval Power System
Hierarchical Digital Twin of a Naval Power System
Kerry Sado
 
Heap Sort (SS).ppt FOR ENGINEERING GRADUATES, BCA, MCA, MTECH, BSC STUDENTS
Heap Sort (SS).ppt FOR ENGINEERING GRADUATES, BCA, MCA, MTECH, BSC STUDENTSHeap Sort (SS).ppt FOR ENGINEERING GRADUATES, BCA, MCA, MTECH, BSC STUDENTS
Heap Sort (SS).ppt FOR ENGINEERING GRADUATES, BCA, MCA, MTECH, BSC STUDENTS
Soumen Santra
 
14 Template Contractual Notice - EOT Application
14 Template Contractual Notice - EOT Application14 Template Contractual Notice - EOT Application
14 Template Contractual Notice - EOT Application
SyedAbiiAzazi1
 
Understanding Inductive Bias in Machine Learning
Understanding Inductive Bias in Machine LearningUnderstanding Inductive Bias in Machine Learning
Understanding Inductive Bias in Machine Learning
SUTEJAS
 
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
obonagu
 
Literature Review Basics and Understanding Reference Management.pptx
Literature Review Basics and Understanding Reference Management.pptxLiterature Review Basics and Understanding Reference Management.pptx
Literature Review Basics and Understanding Reference Management.pptx
Dr Ramhari Poudyal
 
Recycled Concrete Aggregate in Construction Part III
Recycled Concrete Aggregate in Construction Part IIIRecycled Concrete Aggregate in Construction Part III
Recycled Concrete Aggregate in Construction Part III
Aditya Rajan Patra
 
Fundamentals of Induction Motor Drives.pptx
Fundamentals of Induction Motor Drives.pptxFundamentals of Induction Motor Drives.pptx
Fundamentals of Induction Motor Drives.pptx
manasideore6
 
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
bakpo1
 
ACEP Magazine edition 4th launched on 05.06.2024
ACEP Magazine edition 4th launched on 05.06.2024ACEP Magazine edition 4th launched on 05.06.2024
ACEP Magazine edition 4th launched on 05.06.2024
Rahul
 
Technical Drawings introduction to drawing of prisms
Technical Drawings introduction to drawing of prismsTechnical Drawings introduction to drawing of prisms
Technical Drawings introduction to drawing of prisms
heavyhaig
 
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&BDesign and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
Sreedhar Chowdam
 
bank management system in java and mysql report1.pdf
bank management system in java and mysql report1.pdfbank management system in java and mysql report1.pdf
bank management system in java and mysql report1.pdf
Divyam548318
 
CHINA’S GEO-ECONOMIC OUTREACH IN CENTRAL ASIAN COUNTRIES AND FUTURE PROSPECT
CHINA’S GEO-ECONOMIC OUTREACH IN CENTRAL ASIAN COUNTRIES AND FUTURE PROSPECTCHINA’S GEO-ECONOMIC OUTREACH IN CENTRAL ASIAN COUNTRIES AND FUTURE PROSPECT
CHINA’S GEO-ECONOMIC OUTREACH IN CENTRAL ASIAN COUNTRIES AND FUTURE PROSPECT
jpsjournal1
 
哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样
哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样
哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样
insn4465
 
原版制作(unimelb毕业证书)墨尔本大学毕业证Offer一模一样
原版制作(unimelb毕业证书)墨尔本大学毕业证Offer一模一样原版制作(unimelb毕业证书)墨尔本大学毕业证Offer一模一样
原版制作(unimelb毕业证书)墨尔本大学毕业证Offer一模一样
obonagu
 

Recently uploaded (20)

ACRP 4-09 Risk Assessment Method to Support Modification of Airfield Separat...
ACRP 4-09 Risk Assessment Method to Support Modification of Airfield Separat...ACRP 4-09 Risk Assessment Method to Support Modification of Airfield Separat...
ACRP 4-09 Risk Assessment Method to Support Modification of Airfield Separat...
 
Fundamentals of Electric Drives and its applications.pptx
Fundamentals of Electric Drives and its applications.pptxFundamentals of Electric Drives and its applications.pptx
Fundamentals of Electric Drives and its applications.pptx
 
A review on techniques and modelling methodologies used for checking electrom...
A review on techniques and modelling methodologies used for checking electrom...A review on techniques and modelling methodologies used for checking electrom...
A review on techniques and modelling methodologies used for checking electrom...
 
Series of visio cisco devices Cisco_Icons.ppt
Series of visio cisco devices Cisco_Icons.pptSeries of visio cisco devices Cisco_Icons.ppt
Series of visio cisco devices Cisco_Icons.ppt
 
Hierarchical Digital Twin of a Naval Power System
Hierarchical Digital Twin of a Naval Power SystemHierarchical Digital Twin of a Naval Power System
Hierarchical Digital Twin of a Naval Power System
 
Heap Sort (SS).ppt FOR ENGINEERING GRADUATES, BCA, MCA, MTECH, BSC STUDENTS
Heap Sort (SS).ppt FOR ENGINEERING GRADUATES, BCA, MCA, MTECH, BSC STUDENTSHeap Sort (SS).ppt FOR ENGINEERING GRADUATES, BCA, MCA, MTECH, BSC STUDENTS
Heap Sort (SS).ppt FOR ENGINEERING GRADUATES, BCA, MCA, MTECH, BSC STUDENTS
 
14 Template Contractual Notice - EOT Application
14 Template Contractual Notice - EOT Application14 Template Contractual Notice - EOT Application
14 Template Contractual Notice - EOT Application
 
Understanding Inductive Bias in Machine Learning
Understanding Inductive Bias in Machine LearningUnderstanding Inductive Bias in Machine Learning
Understanding Inductive Bias in Machine Learning
 
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
 
Literature Review Basics and Understanding Reference Management.pptx
Literature Review Basics and Understanding Reference Management.pptxLiterature Review Basics and Understanding Reference Management.pptx
Literature Review Basics and Understanding Reference Management.pptx
 
Recycled Concrete Aggregate in Construction Part III
Recycled Concrete Aggregate in Construction Part IIIRecycled Concrete Aggregate in Construction Part III
Recycled Concrete Aggregate in Construction Part III
 
Fundamentals of Induction Motor Drives.pptx
Fundamentals of Induction Motor Drives.pptxFundamentals of Induction Motor Drives.pptx
Fundamentals of Induction Motor Drives.pptx
 
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
 
ACEP Magazine edition 4th launched on 05.06.2024
ACEP Magazine edition 4th launched on 05.06.2024ACEP Magazine edition 4th launched on 05.06.2024
ACEP Magazine edition 4th launched on 05.06.2024
 
Technical Drawings introduction to drawing of prisms
Technical Drawings introduction to drawing of prismsTechnical Drawings introduction to drawing of prisms
Technical Drawings introduction to drawing of prisms
 
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&BDesign and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
 
bank management system in java and mysql report1.pdf
bank management system in java and mysql report1.pdfbank management system in java and mysql report1.pdf
bank management system in java and mysql report1.pdf
 
CHINA’S GEO-ECONOMIC OUTREACH IN CENTRAL ASIAN COUNTRIES AND FUTURE PROSPECT
CHINA’S GEO-ECONOMIC OUTREACH IN CENTRAL ASIAN COUNTRIES AND FUTURE PROSPECTCHINA’S GEO-ECONOMIC OUTREACH IN CENTRAL ASIAN COUNTRIES AND FUTURE PROSPECT
CHINA’S GEO-ECONOMIC OUTREACH IN CENTRAL ASIAN COUNTRIES AND FUTURE PROSPECT
 
哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样
哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样
哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样
 
原版制作(unimelb毕业证书)墨尔本大学毕业证Offer一模一样
原版制作(unimelb毕业证书)墨尔本大学毕业证Offer一模一样原版制作(unimelb毕业证书)墨尔本大学毕业证Offer一模一样
原版制作(unimelb毕业证书)墨尔本大学毕业证Offer一模一样
 

BEM it! Introduction to BEM

  • 1. BEM it! Introduction to BEM Methodology by Varya Stepanova at SC5 Tuesday Streaming, 21.10.2014
  • 3. There is no unified semantic model across different FE technologies ● HTML stands for hypertext I've heard we mostly do web apps... ● CSS offers no structure out of the box Usually a pile of rules put together. Sorry. ● JavaScript uses its own approaches. ...a new one comes with every framework.
  • 4. Frameworks are not enough ● ≈ 8,500 packages in Bower registry ● JavaScript: the most popular language on GitHub Repositories created: ≈ 264,000 in 2013 ≈ 296,000 in 2012
  • 5. BEM to the rescue
  • 6. What is BEM? BEM claims that simple semantic model (Blocks, Elements, and Modifiers) is enough to define the way you author HTML / CSS / JavaScript, structure code and components, set up interaction and scale your project to build an industry-leading service.
  • 7. What is BEM? ● BEM is a methodology, not a framework Semantic model + best practices for all things frontend ● BEM is a fix for web app semantics ...the same as jQuery is a fix for DOM APIs ● Originally introduced by Yandex — 19 million daily audience — 200+ web services — tools, code, tutorials, conferences — open source
  • 9. What is BEM? BLOCK – Standalone part of an interface: ● button ● text field ● flyout ● heading ● menu
  • 10. What is BEM? BLOCK – Standalone part of an interface: ● button ● text field ● flyout ● heading ● menu – Re-usable in different contexts – Self-sufficient
  • 11. What is BEM? ELEMENT – An integral part of a block: ● button ● text field ● flyout ● heading ● menu
  • 12. What is BEM? ELEMENT – An integral part of a block: ● button — contains no elements ● text field label ● flyout title ● heading logo ● menu item
  • 13. What is BEM? ELEMENT – An integral part of a block: ● button — contains no elements ● text field label ● flyout title ● heading logo ● menu item – No standalone meaning outside of a block – Some blocks have no elements
  • 14. What is BEM? MODIFIER – Defines property or state on a block or element: ● button ● text field ● flyout ● heading ● menu item
  • 15. What is BEM? MODIFIER – Defines property or state on a block or element: ● button theme ● text field editable state ● flyout alignment ● heading level ● menu item bullet type
  • 16. What is BEM? MODIFIER – Defines property or state on a block or element: ● button theme ● text field editable state ● flyout alignment ● heading level ● menu item bullet type – Multiple modifiers may co-exist on a single block/element
  • 17. BEM forms a semantic overlay over the existing DOM structure. This overlay is called a BEM tree.
  • 18. DOM tree → BEM tree
  • 19. How does BEM map to DOM? ● Blocks/elems/mods are denoted with CSS classes using a naming convention. ● DOM nodes can be shared: — block1 + block2 may occupy the same container; — element1 + block2 may co-exist on the same node. ● DOM is encapsulated: — complex DOM structure may constitute a single element
  • 20. BEM HOWTO for your beloved project with benefits explained
  • 22. CSS naming conventions “BEM uses CSS class names to denote blocks, elements and modifiers.”
  • 23. CSS naming conventions BLOCK .button .text-field .flyout .heading .menu or with prefix .b-button .b-text-field .b-flyout .b-heading .b-menu
  • 24. CSS naming conventions <ul class=”menu”> <li> <a href=”/more”>Read More</a> </li> <li> <a href=”/buy”>Buy Online</a> </li> <li> <a href=”/buy”>Contact</a> </li> </ul>
  • 25. CSS naming conventions ELEMENT .button__icon .text-field__label .flyout__title .heading__logo .menu__item
  • 26. CSS naming conventions <ul class=”menu”> <li class=”menu__item”> <a href=”/more”>Read More</a> </li> <li class=”menu__item”> <a href=”/buy”>Buy Online</a> </li> <li class=”menu__item”> <a href=”/buy”>Contact</a> </li> </ul>
  • 27. CSS naming conventions MODIFIER .button_theme_dark .text-field_editable .flyout_align_top .heading_level_alpha .menu__item_promo
  • 28. CSS naming conventions MODIFIER as you wish .button--theme--dark .text-field--editable .flyout--align--top .heading--level--alpha .menu__item--promo
  • 29. CSS naming conventions <ul class=”menu”> <li class=”menu__item”> <a href=”/more”>Read More</a> </li> <li class=”menu__item”> <a href=”/buy”>Buy Online</a> </li> <li class=”menu__item”> <a href=”/buy”>Contact</a> </li> </ul>
  • 30. CSS naming conventions <ul class=”menu”> <li class=”menu__item menu__item_promo”> <a href=”/more”>Read More</a> </li> <li class=”menu__item”> <a href=”/buy”>Buy Online</a> </li> <li class=”menu__item”> <a href=”/buy”>Contact</a> </li> </ul>
  • 31. so structure much much semantics wow very code such frontend
  • 32. BEM CSS: best practices 1. Map the whole document to BEM blocks 2. No CSS outside of blocks 3. Independent blocks → no global CSS resets
  • 33. Benefits! Drop tag names and IDs ● Faster selectors ● Re-use same semantics on any tag: — <DIV class=”block”> — <SPAN class=”block”> — <TABLE class=”block”>
  • 34. Benefits! Bye-bye CSS cascade?! Only one CSS class needed to: ● style a block container ● style any element within a block ● add extras/overrides with a modifier Doesn't it cover 90% of your styling needs?
  • 35. Benefits! CSS specificity magic solved Priority of CSS rules: by specificity first, then by rule order td.data { background-color: gray } td.summary { background-color: white } .total-summary { background-color: yellow } <TD class="summary total-summary"> <!-- Still gray, baby :-( --> </TD>
  • 36. Benefits! CSS specificity magic solved Priority of CSS rules: by specificity first, then by rule order td.data { background-color: gray } td.summary { background-color: white } td.total-summary { background-color: yellow } <TD class="summary total-summary"> <!-- This works, I'm yellow now --> </TD>
  • 37. Benefits! Bye-bye CSS cascade?! ...well, not exactly. Example of an element affected by a block modifier: /* theme menu items for a dark theme */ .menu_theme_dark .menu__item { color: white; background-color: darkgray; }
  • 39. Download Help Contact password LLooggiinn Main username
  • 40. mmeennuu Download Help Contact password LLooggiinn Main username hheeaaddeerr tteexxtt iinnppuutt tteexxtt iinnppuutt bbuuttttoonn
  • 41. Download Help Contact _size_small _size_small _primary password LLooggiinn Main username
  • 42. Download Help Contact password LLooggiinn Main username .header .input { font-size: 0.85em } .header .button { background: navy }
  • 43. Download Help Contact password LLooggiinn Main username .header .input { font-size: 0.85em } .header .button { background: navy } !
  • 45. JavaScript Components → Blocks Work with BEM tree, not DOM tree
  • 46. JavaScript deals with BEM blockObj blockObj.setMod('active'); // <div class=”block block_active”> blockObj.delMod('active); // <div class=”block”>
  • 47. JavaScript deals with BEM BlockObj.do({ 'active': function() { // do smth when active }, 'disabled': function() { // do something when disabled } });
  • 48. JavaScript i-bem.js framework by Yandex + tutorial http://bit.ly/bem-js-tutorial/ ● First English docs (expect more!) ● 100% BEM-based declarative API ● Part of a larger bem-core library
  • 49. HTML is no longer semantic. JavaScript is.
  • 51. BEM is the universal language for developers and designers, the bridge across technology gaps.
  • 52. Build your block library. The code itself is the styleguide.
  • 53. UX + Frontend ● Live style guide ● Always up-to-date ● Prototyping mapped to code from day one ● Designers and devs speak the same language ● Good for making early estimates
  • 55. File and folder structure Flat block structure with a folder for each block. Simple structure for BEM beginners: /block block.css block.js block.tpl ...whatever you need
  • 56. File and folder structure Advanced structure to expose semantics /block /__elem1 block__elem1.css block__elem1.tpl /_mod block_mod.css block.css block.js block.tpl
  • 57. Bundles for browsers page.css: @import url(“header/header.css”); @import url(“button/button.css”); @import url(“button/button_promo.css”); page.js: /* include: button.js */ /* include: login.js */
  • 58. Build process and deployment Use a build tool! Borschik: an open-source build tool by Yandex Code: https://github.com/bem/borschik English docs: http://bem.info/articles/borschik
  • 59. Build process and deployment Any familiar tool can be a builder Gulp: Example: https://github.com/getbem/getbem.com
  • 60. BEM gives answers to: 1. Where is code for this interface object? ●CSS ● JS ●Templates ●Documentation 2.Can I remove this piece of code? 3.How do I name this new item?
  • 62. Thank you SC5! @varya_en http://varya.me