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

PDF
CSS - OOCSS, SMACSS and more
PDF
CSS For Backend Developers
PDF
BEM - CSS, Seriously
PDF
BEM it! Introduction to BEM methodology
PDF
BEM It! for Brandwatch
PDF
Responsive Web Design Tutorial PDF for Beginners
PDF
OOCSS, SMACSS or BEM?
PDF
Introduction to HTML and CSS
CSS - OOCSS, SMACSS and more
CSS For Backend Developers
BEM - CSS, Seriously
BEM it! Introduction to BEM methodology
BEM It! for Brandwatch
Responsive Web Design Tutorial PDF for Beginners
OOCSS, SMACSS or BEM?
Introduction to HTML and CSS

What's hot (20)

PPT
Cascading Style Sheets (CSS) help
PDF
DRY CSS A don’t-repeat-yourself methodology for creating efficient, unified a...
PPTX
Presentation about html5 css3
PDF
HTML/CSS Crash Course (april 4 2017)
PPT
Html basics
PDF
CSS Grid Layout Introduction
PDF
Aem dispatcher – tips & tricks
PDF
CSS Best practice
PPTX
Introducing CSS Grid
PPTX
Database versioning with liquibase
PDF
Intro to HTML and CSS basics
PDF
Intro to HTML & CSS
PDF
The benefits of BEM CSS
PDF
Corso di HTML5 e CSS
PPTX
The Box Model [CSS Introduction]
PDF
Reverse Engineering .NET - Advanced Patching, Playing with IL
PPT
Html & Css presentation
PDF
Introduction to CSS3
PPTX
Introduction to html
Cascading Style Sheets (CSS) help
DRY CSS A don’t-repeat-yourself methodology for creating efficient, unified a...
Presentation about html5 css3
HTML/CSS Crash Course (april 4 2017)
Html basics
CSS Grid Layout Introduction
Aem dispatcher – tips & tricks
CSS Best practice
Introducing CSS Grid
Database versioning with liquibase
Intro to HTML and CSS basics
Intro to HTML & CSS
The benefits of BEM CSS
Corso di HTML5 e CSS
The Box Model [CSS Introduction]
Reverse Engineering .NET - Advanced Patching, Playing with IL
Html & Css presentation
Introduction to CSS3
Introduction to html
Ad

Viewers also liked (20)

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

Similar to BEM it! Introduction to BEM (20)

PDF
BEM it!
PPTX
BEM methodology overview
PDF
PPTX
Functional Css
PPTX
Let's BEM together
PDF
BEM Methodology — @Frontenders Ticino —17/09/2014
PDF
The Thinking behind BEM
PPTX
Bliblidotcom - Reintroduction BEM CSS
PDF
BEM for Javascript at CampJS III
PDF
Workshop SASS for BEM development
PDF
Introduction to BEM Methodology
PDF
Learn BEM: CSS Naming Convention
PDF
What is Modular CSS?
PDF
BEM and Component Development
PDF
Bem methodology
PDF
Maintainable Frontend Development with BEM
PDF
Css Systems
PDF
Style Guide Driven Development: All Hail the Robot Overlords!
PDF
OOCSS, SMACSS or BEM, what is the question...
BEM it!
BEM methodology overview
Functional Css
Let's BEM together
BEM Methodology — @Frontenders Ticino —17/09/2014
The Thinking behind BEM
Bliblidotcom - Reintroduction BEM CSS
BEM for Javascript at CampJS III
Workshop SASS for BEM development
Introduction to BEM Methodology
Learn BEM: CSS Naming Convention
What is Modular CSS?
BEM and Component Development
Bem methodology
Maintainable Frontend Development with BEM
Css Systems
Style Guide Driven Development: All Hail the Robot Overlords!
OOCSS, SMACSS or BEM, what is the question...

More from Varya Stepanova (9)

PDF
Design systems on the web
PDF
SC5 Style Guide Generator
PDF
Modular development
PDF
BEM. What you can borrow from Yandex frontend dev
PDF
Тема для WordPress в БЭМ
PDF
Шаблонизатор BEMHTML
PDF
Использование библиотеки bem-bl
PDF
JavaScript в БЭМ терминах
KEY
Использование библиотеки bem-bl
Design systems on the web
SC5 Style Guide Generator
Modular development
BEM. What you can borrow from Yandex frontend dev
Тема для WordPress в БЭМ
Шаблонизатор BEMHTML
Использование библиотеки bem-bl
JavaScript в БЭМ терминах
Использование библиотеки bem-bl

Recently uploaded (20)

PDF
Unit I ESSENTIAL OF DIGITAL MARKETING.pdf
DOCX
573137875-Attendance-Management-System-original
PPT
Introduction, IoT Design Methodology, Case Study on IoT System for Weather Mo...
PDF
Automation-in-Manufacturing-Chapter-Introduction.pdf
PPT
Mechanical Engineering MATERIALS Selection
PPTX
MET 305 2019 SCHEME MODULE 2 COMPLETE.pptx
PPTX
Infosys Presentation by1.Riyan Bagwan 2.Samadhan Naiknavare 3.Gaurav Shinde 4...
PPTX
Geodesy 1.pptx...............................................
PPTX
UNIT-1 - COAL BASED THERMAL POWER PLANTS
PPTX
Current and future trends in Computer Vision.pptx
PPTX
Artificial Intelligence
PPTX
Internet of Things (IOT) - A guide to understanding
PDF
July 2025 - Top 10 Read Articles in International Journal of Software Enginee...
PPTX
Safety Seminar civil to be ensured for safe working.
PDF
Model Code of Practice - Construction Work - 21102022 .pdf
PDF
TFEC-4-2020-Design-Guide-for-Timber-Roof-Trusses.pdf
PDF
Mohammad Mahdi Farshadian CV - Prospective PhD Student 2026
PDF
composite construction of structures.pdf
PPTX
UNIT 4 Total Quality Management .pptx
PPTX
M Tech Sem 1 Civil Engineering Environmental Sciences.pptx
Unit I ESSENTIAL OF DIGITAL MARKETING.pdf
573137875-Attendance-Management-System-original
Introduction, IoT Design Methodology, Case Study on IoT System for Weather Mo...
Automation-in-Manufacturing-Chapter-Introduction.pdf
Mechanical Engineering MATERIALS Selection
MET 305 2019 SCHEME MODULE 2 COMPLETE.pptx
Infosys Presentation by1.Riyan Bagwan 2.Samadhan Naiknavare 3.Gaurav Shinde 4...
Geodesy 1.pptx...............................................
UNIT-1 - COAL BASED THERMAL POWER PLANTS
Current and future trends in Computer Vision.pptx
Artificial Intelligence
Internet of Things (IOT) - A guide to understanding
July 2025 - Top 10 Read Articles in International Journal of Software Enginee...
Safety Seminar civil to be ensured for safe working.
Model Code of Practice - Construction Work - 21102022 .pdf
TFEC-4-2020-Design-Guide-for-Timber-Roof-Trusses.pdf
Mohammad Mahdi Farshadian CV - Prospective PhD Student 2026
composite construction of structures.pdf
UNIT 4 Total Quality Management .pptx
M Tech Sem 1 Civil Engineering Environmental Sciences.pptx

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