SlideShare uma empresa Scribd logo
1 de 31
Baixar para ler offline
BEM it! 
Martin Pešout / front-end developer at dotBlue 
@martinpesout
What is BEM? 
WHAT + WHY + HOW
Milestone 2013 
• 2013 
• boom of responsive design (RWD) 
• RWD means also more complex CSS styles
Milestone 2013 
• 2013 
• boom of responsive design (RWD) 
• RWD means also more complex CSS styles 
• 2014 
• boom of optimization of developed responsive 
webpages 
• Fluid web doesn’t mean fast web on mobile 
connection
Web development in 
2014 needs methodology 
We really need good rules 
! 
! 
… rather than frameworks
Why has been BEM created? 
• The way how to organize code for whole team 
on big project 
• Reusable components 
• Long-standing components 
• Easy to learn for new team members
It’s not magic 
BEM is not hard to learn. A 
lot of articles and examples 
everywhere.
Don’t use #ID selectors!
BEM = block + element 
+ modifier
Block 
• Standalone part of interface 
• button 
• menu 
• heading
Block 
• Standalone part of interface 
• button 
• menu 
• heading 
• Reusable 
• Independent on other styles
Element 
• An internal part of block 
• button 
• menu 
• heading
Element 
• An internal part of block 
• button - icon 
• menu - item 
• heading - logo
Element 
• An internal part of block 
• button - icon 
• menu - item 
• heading - logo 
• No standalone meaning outside of a block 
• Some blocks have no element(s)
Modifier 
• Defines the state of property on a block or 
element 
• button 
• menu - item 
• heading
Modifier 
• Defines the state of property on a block or 
element 
• button - color 
• menu - item - active state 
• heading - level
BEM uses class names to 
describe block, elements 
and modifiers
Naming convenction 
block 
btn 
menu 
heading
Naming convenction 
block__element 
btn__icon 
menu__item 
heading__logo
Naming convenction 
block__element––modifier 
btn––large 
btn__icon––arrow 
menu––secondary 
menu__item––active
Header 
<div class="header header--main"> 
<h1 class=“header__title">Brian &amp; Jessica</h1> 
<div class=“header__description”> 
Main information about our wedding 
</div> 
</div>
Common mistakes 
<div class="header header--main"> 
<h1>Brian &amp; Jessica</h1> 
<p> 
Main information about our wedding 
</p> 
</div> 
• Don’t use shared styles 
• No common resets (only normalize.css is allowed) 
• No CSS definition outside of block
Button 
<a href="#love-story" class="action-btn action-btn–– 
arrow-down”></a>
Banner 
<div class=“banner"> 
<img src="/images/main-banner-large.jpg" alt="Bride 
and groom” class="banner__img"> 
<div class="banner__title">Soon together</div> 
<a href="#love-story" class="banner__btn action-btn 
action-btn--arrow-down"></a> 
</div>
Banner 
<div class=“banner"> 
<img src="/images/main-banner-large.jpg" alt="Bride 
and groom” class="banner__img"> 
<div class="banner__title">Soon together</div> 
<a href="#love-story" class="banner__btn action-btn 
action-btn--arrow-down"></a> 
</div> 
• We can combine more blocks together
Independent styles 
• You can always change syntax and have always 
the same look 
<ul class=“menu”> 
<li class=“menu__item”>Home</li> 
<li class=“menu__item menu__item––active”>Contact</li> 
</ul> 
<div class=“menu”> 
<div class=“menu__item”>Home</div> 
<div class=“menu__item menu__item––active”>Contact</div> 
</div>
Another best practices 
• Preprocessor can help you to organize your 
styles to better file structure 
• Use prefix js- class or ID prefix for JavaScript 
selectors
Thank you 
Martin Pešout / front-end developer at dotBlue 
@martinpesout

Mais conteúdo relacionado

Semelhante a BEM it!

BEM it! Introduction to BEM methodology
BEM it! Introduction to BEM methodologyBEM it! Introduction to BEM methodology
BEM it! Introduction to BEM methodologyVarya Stepanova
 
BEM It! for Brandwatch
BEM It! for BrandwatchBEM It! for Brandwatch
BEM It! for BrandwatchMax Shirshin
 
Code &amp; design your first website (3:16)
Code &amp; design your first website (3:16)Code &amp; design your first website (3:16)
Code &amp; design your first website (3:16)Thinkful
 
HTML5- Create divisions in a web page
HTML5- Create divisions in a web pageHTML5- Create divisions in a web page
HTML5- Create divisions in a web pageGrayzon Gonzales, LPT
 
WordPress theme setting page
WordPress theme setting pageWordPress theme setting page
WordPress theme setting pageNaeem Junejo
 
Code & Design your first website 4/18
Code & Design your first website 4/18Code & Design your first website 4/18
Code & Design your first website 4/18TJ Stalcup
 
Maintainable Frontend Development with BEM
Maintainable Frontend Development with BEMMaintainable Frontend Development with BEM
Maintainable Frontend Development with BEMVarya Stepanova
 
From a Fireworks Comp to a Genesis Child Theme, Step by Step
From a Fireworks Comp to a Genesis Child Theme, Step by StepFrom a Fireworks Comp to a Genesis Child Theme, Step by Step
From a Fireworks Comp to a Genesis Child Theme, Step by StepEast Bay WordPress Meetup
 
Html css crash course may 11th, atlanta
Html css crash course may 11th, atlantaHtml css crash course may 11th, atlanta
Html css crash course may 11th, atlantaThinkful
 
Iasi code camp 12 october 2013 shadow dom - mihai bîrsan
Iasi code camp 12 october 2013   shadow dom - mihai bîrsanIasi code camp 12 october 2013   shadow dom - mihai bîrsan
Iasi code camp 12 october 2013 shadow dom - mihai bîrsanCodecamp Romania
 
Web development basics (Part-1)
Web development basics (Part-1)Web development basics (Part-1)
Web development basics (Part-1)Rajat Pratap Singh
 
GWT.create 2013: Themeing GWT Applications with the Appearance Pattern
GWT.create 2013: Themeing GWT Applications with the Appearance PatternGWT.create 2013: Themeing GWT Applications with the Appearance Pattern
GWT.create 2013: Themeing GWT Applications with the Appearance Patternniloc132
 
In Mind Cloud - Product Release - 2208
In Mind Cloud - Product Release - 2208In Mind Cloud - Product Release - 2208
In Mind Cloud - Product Release - 2208In Mind Cloud
 
Creating a Great XPages User Interface
Creating a Great XPages User InterfaceCreating a Great XPages User Interface
Creating a Great XPages User InterfaceTeamstudio
 
Creating a Great XPages User Interface, TLCC Teamstudio Webinar - Feb, 2014
Creating a Great XPages User Interface, TLCC Teamstudio Webinar - Feb, 2014Creating a Great XPages User Interface, TLCC Teamstudio Webinar - Feb, 2014
Creating a Great XPages User Interface, TLCC Teamstudio Webinar - Feb, 2014Howard Greenberg
 
Introduction to Django CMS
Introduction to Django CMS Introduction to Django CMS
Introduction to Django CMS Pim Van Heuven
 
HTML(5) and CSS(3) for beginners - I
HTML(5) and CSS(3) for beginners - IHTML(5) and CSS(3) for beginners - I
HTML(5) and CSS(3) for beginners - Ivincentleeuwen
 
Css types internal, external and inline (1)
Css types internal, external and inline (1)Css types internal, external and inline (1)
Css types internal, external and inline (1)Webtech Learning
 

Semelhante a BEM it! (20)

BEM it! Introduction to BEM methodology
BEM it! Introduction to BEM methodologyBEM it! Introduction to BEM methodology
BEM it! Introduction to BEM methodology
 
BEM It! for Brandwatch
BEM It! for BrandwatchBEM It! for Brandwatch
BEM It! for Brandwatch
 
Code &amp; design your first website (3:16)
Code &amp; design your first website (3:16)Code &amp; design your first website (3:16)
Code &amp; design your first website (3:16)
 
BEM it!
BEM it!BEM it!
BEM it!
 
HTML5- Create divisions in a web page
HTML5- Create divisions in a web pageHTML5- Create divisions in a web page
HTML5- Create divisions in a web page
 
WordPress theme setting page
WordPress theme setting pageWordPress theme setting page
WordPress theme setting page
 
Code & Design your first website 4/18
Code & Design your first website 4/18Code & Design your first website 4/18
Code & Design your first website 4/18
 
Maintainable Frontend Development with BEM
Maintainable Frontend Development with BEMMaintainable Frontend Development with BEM
Maintainable Frontend Development with BEM
 
From a Fireworks Comp to a Genesis Child Theme, Step by Step
From a Fireworks Comp to a Genesis Child Theme, Step by StepFrom a Fireworks Comp to a Genesis Child Theme, Step by Step
From a Fireworks Comp to a Genesis Child Theme, Step by Step
 
Html css crash course may 11th, atlanta
Html css crash course may 11th, atlantaHtml css crash course may 11th, atlanta
Html css crash course may 11th, atlanta
 
Oracle Apps - Forms
Oracle Apps - FormsOracle Apps - Forms
Oracle Apps - Forms
 
Iasi code camp 12 october 2013 shadow dom - mihai bîrsan
Iasi code camp 12 october 2013   shadow dom - mihai bîrsanIasi code camp 12 october 2013   shadow dom - mihai bîrsan
Iasi code camp 12 october 2013 shadow dom - mihai bîrsan
 
Web development basics (Part-1)
Web development basics (Part-1)Web development basics (Part-1)
Web development basics (Part-1)
 
GWT.create 2013: Themeing GWT Applications with the Appearance Pattern
GWT.create 2013: Themeing GWT Applications with the Appearance PatternGWT.create 2013: Themeing GWT Applications with the Appearance Pattern
GWT.create 2013: Themeing GWT Applications with the Appearance Pattern
 
In Mind Cloud - Product Release - 2208
In Mind Cloud - Product Release - 2208In Mind Cloud - Product Release - 2208
In Mind Cloud - Product Release - 2208
 
Creating a Great XPages User Interface
Creating a Great XPages User InterfaceCreating a Great XPages User Interface
Creating a Great XPages User Interface
 
Creating a Great XPages User Interface, TLCC Teamstudio Webinar - Feb, 2014
Creating a Great XPages User Interface, TLCC Teamstudio Webinar - Feb, 2014Creating a Great XPages User Interface, TLCC Teamstudio Webinar - Feb, 2014
Creating a Great XPages User Interface, TLCC Teamstudio Webinar - Feb, 2014
 
Introduction to Django CMS
Introduction to Django CMS Introduction to Django CMS
Introduction to Django CMS
 
HTML(5) and CSS(3) for beginners - I
HTML(5) and CSS(3) for beginners - IHTML(5) and CSS(3) for beginners - I
HTML(5) and CSS(3) for beginners - I
 
Css types internal, external and inline (1)
Css types internal, external and inline (1)Css types internal, external and inline (1)
Css types internal, external and inline (1)
 

BEM it!

  • 1. BEM it! Martin Pešout / front-end developer at dotBlue @martinpesout
  • 2.
  • 3. What is BEM? WHAT + WHY + HOW
  • 4. Milestone 2013 • 2013 • boom of responsive design (RWD) • RWD means also more complex CSS styles
  • 5. Milestone 2013 • 2013 • boom of responsive design (RWD) • RWD means also more complex CSS styles • 2014 • boom of optimization of developed responsive webpages • Fluid web doesn’t mean fast web on mobile connection
  • 6. Web development in 2014 needs methodology We really need good rules ! ! … rather than frameworks
  • 7. Why has been BEM created? • The way how to organize code for whole team on big project • Reusable components • Long-standing components • Easy to learn for new team members
  • 8. It’s not magic BEM is not hard to learn. A lot of articles and examples everywhere.
  • 9. Don’t use #ID selectors!
  • 10. BEM = block + element + modifier
  • 11. Block • Standalone part of interface • button • menu • heading
  • 12. Block • Standalone part of interface • button • menu • heading • Reusable • Independent on other styles
  • 13. Element • An internal part of block • button • menu • heading
  • 14. Element • An internal part of block • button - icon • menu - item • heading - logo
  • 15. Element • An internal part of block • button - icon • menu - item • heading - logo • No standalone meaning outside of a block • Some blocks have no element(s)
  • 16. Modifier • Defines the state of property on a block or element • button • menu - item • heading
  • 17. Modifier • Defines the state of property on a block or element • button - color • menu - item - active state • heading - level
  • 18. BEM uses class names to describe block, elements and modifiers
  • 19. Naming convenction block btn menu heading
  • 20. Naming convenction block__element btn__icon menu__item heading__logo
  • 21. Naming convenction block__element––modifier btn––large btn__icon––arrow menu––secondary menu__item––active
  • 22.
  • 23. Header <div class="header header--main"> <h1 class=“header__title">Brian &amp; Jessica</h1> <div class=“header__description”> Main information about our wedding </div> </div>
  • 24. Common mistakes <div class="header header--main"> <h1>Brian &amp; Jessica</h1> <p> Main information about our wedding </p> </div> • Don’t use shared styles • No common resets (only normalize.css is allowed) • No CSS definition outside of block
  • 25.
  • 26. Button <a href="#love-story" class="action-btn action-btn–– arrow-down”></a>
  • 27. Banner <div class=“banner"> <img src="/images/main-banner-large.jpg" alt="Bride and groom” class="banner__img"> <div class="banner__title">Soon together</div> <a href="#love-story" class="banner__btn action-btn action-btn--arrow-down"></a> </div>
  • 28. Banner <div class=“banner"> <img src="/images/main-banner-large.jpg" alt="Bride and groom” class="banner__img"> <div class="banner__title">Soon together</div> <a href="#love-story" class="banner__btn action-btn action-btn--arrow-down"></a> </div> • We can combine more blocks together
  • 29. Independent styles • You can always change syntax and have always the same look <ul class=“menu”> <li class=“menu__item”>Home</li> <li class=“menu__item menu__item––active”>Contact</li> </ul> <div class=“menu”> <div class=“menu__item”>Home</div> <div class=“menu__item menu__item––active”>Contact</div> </div>
  • 30. Another best practices • Preprocessor can help you to organize your styles to better file structure • Use prefix js- class or ID prefix for JavaScript selectors
  • 31. Thank you Martin Pešout / front-end developer at dotBlue @martinpesout