SlideShare une entreprise Scribd logo
1  sur  8
BEM
Block-Element-Modifier
guptazee.com
What is BEM?
BEM is a
methodology
It was coined by a
company named
Yandex located in
Moscow
It is a popular
naming conventions
for classes in HTML
and CSS
guptazee.com
What is the
use of BEM?
BEM allows to write maintainable CSS code.
It is used to write reusable CSS components.
Overall, BEM is modular, flexible and easy to learn.
guptazee.com
Benefits of
BEM over
Traditional CSS
approach
BEM can help to
know what a CSS
selector does just
by reading out its
name.
This naming
convention also
tells where a
selector can be
used.
One can find out
the relationships
between class-
names just by
reading out the
name.
BEM divides the
user interface (UI)
into independent
blocks.
guptazee.com
How to use
BEM (Block,
Element,
Modifier)?
• Block- As it has been mentioned earlier, BEM divides the UI into
independent blocks. The ‘block’ signifies a component, or a standalone
object on the page. The classes can be named after each such block.
• Element- it lives within a block. It signifies a single part of a component.
There can be multiple elements in a component that together make up a
whole feature of the block. These classes can be named by prefixing by
block’s class, followed by double underscores. For example: .block_
_element
• Modifier- when block or element has some sort of variants in terms of
color, size and appearance then the classes further can be expanded.
Here, the classes would be prefixed by block’s or element’s class, followed
by double hyphens. For example: .block--modifier or .block_ _element--
modifier
guptazee.com
Real World
Example
• Let’s take an example of a modal that has been used in an application.
• Here, the modal can be considered as a component and it can be targeted by using a class at
the block level, say .modal.
• Now, a modal can have few common elements like a header, a body and a footer.
• So, the modal header can have a class .modal_ _header, its body can have .modal_ _body and
its footer element can be named as .modal_ _footer. These three elements are the basic
elements of a modal.
• Further, a modal can be sized as full-screen, mid-sized or a smaller one. Hence, we can have
three variants of the modal. So, its classes can be written as .modal--full, .modal--mid, and
.modal--small
• There are also chances that its element can have some variants like header can be in black color
or body contents are centrally aligned and footer is disable. Now, the classes for these elements
can be written as .modal_ _header--black, .modal_ _body--center and .modal_ _footer--
disable.
• In this way, you can see that the classes defined above are relevant to a single component and
that is a .modal.
guptazee.com
Few More Instances
• A button can also be a component. e.g. .button
• It can also be have size and color variants. e.g. .button- -small, .button- -
large
• It can be primary and secondary. e.g. .button- -primary, .button- -
secondary
• It can also have elements like header and label. e.g. .button_ _header,
.button_ _text
guptazee.com
Summary
• This is how BEM methodology works. By following this naming
convention, one can easily make his CSS scalable, maintainable,
and reusable.
• It also helps to reduce specificity of a selector.
• Since, each components are independent blocks. Hence, it can
be re-used easily without thinking of code mess-ups.
• As says, comments are must thing. One should write as much
comments as he feels it should be. It helps other coders to
understand your mindset and strategies.
• At last not the least, BEM is not exceptional you can use
conventions of your own as well. But, it should be in the same
way as BEM says, then only one can be benefitted.
I am really thankful for your
valuable time.
guptazee.com

Contenu connexe

Similaire à Let's BEM together

BEM It! for Brandwatch
BEM It! for BrandwatchBEM It! for Brandwatch
BEM It! for BrandwatchMax Shirshin
 
BEM it! Introduction to BEM
BEM it! Introduction to BEMBEM it! Introduction to BEM
BEM it! Introduction to BEMVarya Stepanova
 
Blockity McBlock Blocks, Oh My!
Blockity McBlock Blocks, Oh My!Blockity McBlock Blocks, Oh My!
Blockity McBlock Blocks, Oh My!Evan Mullins
 
Workshop SASS for BEM development
Workshop SASS for BEM developmentWorkshop SASS for BEM development
Workshop SASS for BEM developmentVittorio Vittori
 
BEM it! Introduction to BEM methodology
BEM it! Introduction to BEM methodologyBEM it! Introduction to BEM methodology
BEM it! Introduction to BEM methodologyVarya Stepanova
 
HTML and CSS Coding Standards
HTML and CSS Coding StandardsHTML and CSS Coding Standards
HTML and CSS Coding StandardsSaajan Maharjan
 
Intro to OOCSS Workshop
Intro to OOCSS WorkshopIntro to OOCSS Workshop
Intro to OOCSS WorkshopJulie Cameron
 
Drupalese 101: DrupalCamp Atlanta 2014
Drupalese 101: DrupalCamp Atlanta 2014Drupalese 101: DrupalCamp Atlanta 2014
Drupalese 101: DrupalCamp Atlanta 2014Annika Garbers
 
Bootstrap Paragraphs for Drupal 8
Bootstrap Paragraphs for Drupal 8Bootstrap Paragraphs for Drupal 8
Bootstrap Paragraphs for Drupal 8Jim Birch
 
Wordpress workflow for an agency world
Wordpress workflow for an agency worldWordpress workflow for an agency world
Wordpress workflow for an agency worldChris Lowe
 
Responsive Design and Bootstrap
Responsive Design  and BootstrapResponsive Design  and Bootstrap
Responsive Design and BootstrapMahmoudOHassouna
 
Vanilla Forums Theme Guide
Vanilla Forums Theme GuideVanilla Forums Theme Guide
Vanilla Forums Theme GuideVanilla Forums
 
full-site-editing-theme-presentation.pptx
full-site-editing-theme-presentation.pptxfull-site-editing-theme-presentation.pptx
full-site-editing-theme-presentation.pptxPlasterdog Web Design
 
Meetup: The big change coming to WordPress in 2018 - Gutenberg
Meetup: The big change coming to WordPress in 2018 - GutenbergMeetup: The big change coming to WordPress in 2018 - Gutenberg
Meetup: The big change coming to WordPress in 2018 - GutenbergEvan Mullins
 
Meetup: The big change coming to WordPress in 2018 - Gutenberg
Meetup: The big change coming to WordPress in 2018 - GutenbergMeetup: The big change coming to WordPress in 2018 - Gutenberg
Meetup: The big change coming to WordPress in 2018 - GutenbergMickey Mellen
 
How to customise Joomla
How to customise JoomlaHow to customise Joomla
How to customise JoomlaTim Plummer
 

Similaire à Let's BEM together (20)

BEM It! for Brandwatch
BEM It! for BrandwatchBEM It! for Brandwatch
BEM It! for Brandwatch
 
BEM it! Introduction to BEM
BEM it! Introduction to BEMBEM it! Introduction to BEM
BEM it! Introduction to BEM
 
Blockity McBlock Blocks, Oh My!
Blockity McBlock Blocks, Oh My!Blockity McBlock Blocks, Oh My!
Blockity McBlock Blocks, Oh My!
 
Workshop SASS for BEM development
Workshop SASS for BEM developmentWorkshop SASS for BEM development
Workshop SASS for BEM development
 
BEM it! Introduction to BEM methodology
BEM it! Introduction to BEM methodologyBEM it! Introduction to BEM methodology
BEM it! Introduction to BEM methodology
 
HTML and CSS Coding Standards
HTML and CSS Coding StandardsHTML and CSS Coding Standards
HTML and CSS Coding Standards
 
Intro to OOCSS Workshop
Intro to OOCSS WorkshopIntro to OOCSS Workshop
Intro to OOCSS Workshop
 
Drupalese 101: DrupalCamp Atlanta 2014
Drupalese 101: DrupalCamp Atlanta 2014Drupalese 101: DrupalCamp Atlanta 2014
Drupalese 101: DrupalCamp Atlanta 2014
 
Bootstrap Paragraphs for Drupal 8
Bootstrap Paragraphs for Drupal 8Bootstrap Paragraphs for Drupal 8
Bootstrap Paragraphs for Drupal 8
 
BEM methodology overview
BEM methodology overviewBEM methodology overview
BEM methodology overview
 
Wordpress workflow for an agency world
Wordpress workflow for an agency worldWordpress workflow for an agency world
Wordpress workflow for an agency world
 
BEM it!
BEM it!BEM it!
BEM it!
 
DHTML
DHTMLDHTML
DHTML
 
What is Modular CSS?
What is Modular CSS?What is Modular CSS?
What is Modular CSS?
 
Responsive Design and Bootstrap
Responsive Design  and BootstrapResponsive Design  and Bootstrap
Responsive Design and Bootstrap
 
Vanilla Forums Theme Guide
Vanilla Forums Theme GuideVanilla Forums Theme Guide
Vanilla Forums Theme Guide
 
full-site-editing-theme-presentation.pptx
full-site-editing-theme-presentation.pptxfull-site-editing-theme-presentation.pptx
full-site-editing-theme-presentation.pptx
 
Meetup: The big change coming to WordPress in 2018 - Gutenberg
Meetup: The big change coming to WordPress in 2018 - GutenbergMeetup: The big change coming to WordPress in 2018 - Gutenberg
Meetup: The big change coming to WordPress in 2018 - Gutenberg
 
Meetup: The big change coming to WordPress in 2018 - Gutenberg
Meetup: The big change coming to WordPress in 2018 - GutenbergMeetup: The big change coming to WordPress in 2018 - Gutenberg
Meetup: The big change coming to WordPress in 2018 - Gutenberg
 
How to customise Joomla
How to customise JoomlaHow to customise Joomla
How to customise Joomla
 

Dernier

Cloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEECloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEEVICTOR MAESTRE RAMIREZ
 
Odoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 EnterpriseOdoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 Enterprisepreethippts
 
Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...Velvetech LLC
 
Cyber security and its impact on E commerce
Cyber security and its impact on E commerceCyber security and its impact on E commerce
Cyber security and its impact on E commercemanigoyal112
 
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...confluent
 
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...Matt Ray
 
CRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. SalesforceCRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. SalesforceBrainSell Technologies
 
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxTier1 app
 
英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作qr0udbr0
 
What are the key points to focus on before starting to learn ETL Development....
What are the key points to focus on before starting to learn ETL Development....What are the key points to focus on before starting to learn ETL Development....
What are the key points to focus on before starting to learn ETL Development....kzayra69
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityNeo4j
 
PREDICTING RIVER WATER QUALITY ppt presentation
PREDICTING  RIVER  WATER QUALITY  ppt presentationPREDICTING  RIVER  WATER QUALITY  ppt presentation
PREDICTING RIVER WATER QUALITY ppt presentationvaddepallysandeep122
 
Best Web Development Agency- Idiosys USA.pdf
Best Web Development Agency- Idiosys USA.pdfBest Web Development Agency- Idiosys USA.pdf
Best Web Development Agency- Idiosys USA.pdfIdiosysTechnologies1
 
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...OnePlan Solutions
 
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company OdishaBalasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odishasmiwainfosol
 
How to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion ApplicationHow to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion ApplicationBradBedford3
 
Ahmed Motair CV April 2024 (Senior SW Developer)
Ahmed Motair CV April 2024 (Senior SW Developer)Ahmed Motair CV April 2024 (Senior SW Developer)
Ahmed Motair CV April 2024 (Senior SW Developer)Ahmed Mater
 
Unveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsUnveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsAhmed Mohamed
 
What is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWhat is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWave PLM
 

Dernier (20)

Cloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEECloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEE
 
Odoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 EnterpriseOdoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 Enterprise
 
Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...
 
Cyber security and its impact on E commerce
Cyber security and its impact on E commerceCyber security and its impact on E commerce
Cyber security and its impact on E commerce
 
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
 
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
 
CRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. SalesforceCRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. Salesforce
 
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
 
英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作
 
What are the key points to focus on before starting to learn ETL Development....
What are the key points to focus on before starting to learn ETL Development....What are the key points to focus on before starting to learn ETL Development....
What are the key points to focus on before starting to learn ETL Development....
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered Sustainability
 
PREDICTING RIVER WATER QUALITY ppt presentation
PREDICTING  RIVER  WATER QUALITY  ppt presentationPREDICTING  RIVER  WATER QUALITY  ppt presentation
PREDICTING RIVER WATER QUALITY ppt presentation
 
Best Web Development Agency- Idiosys USA.pdf
Best Web Development Agency- Idiosys USA.pdfBest Web Development Agency- Idiosys USA.pdf
Best Web Development Agency- Idiosys USA.pdf
 
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
 
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company OdishaBalasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
 
Advantages of Odoo ERP 17 for Your Business
Advantages of Odoo ERP 17 for Your BusinessAdvantages of Odoo ERP 17 for Your Business
Advantages of Odoo ERP 17 for Your Business
 
How to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion ApplicationHow to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion Application
 
Ahmed Motair CV April 2024 (Senior SW Developer)
Ahmed Motair CV April 2024 (Senior SW Developer)Ahmed Motair CV April 2024 (Senior SW Developer)
Ahmed Motair CV April 2024 (Senior SW Developer)
 
Unveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsUnveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML Diagrams
 
What is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWhat is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need It
 

Let's BEM together

  • 2. What is BEM? BEM is a methodology It was coined by a company named Yandex located in Moscow It is a popular naming conventions for classes in HTML and CSS guptazee.com
  • 3. What is the use of BEM? BEM allows to write maintainable CSS code. It is used to write reusable CSS components. Overall, BEM is modular, flexible and easy to learn. guptazee.com
  • 4. Benefits of BEM over Traditional CSS approach BEM can help to know what a CSS selector does just by reading out its name. This naming convention also tells where a selector can be used. One can find out the relationships between class- names just by reading out the name. BEM divides the user interface (UI) into independent blocks. guptazee.com
  • 5. How to use BEM (Block, Element, Modifier)? • Block- As it has been mentioned earlier, BEM divides the UI into independent blocks. The ‘block’ signifies a component, or a standalone object on the page. The classes can be named after each such block. • Element- it lives within a block. It signifies a single part of a component. There can be multiple elements in a component that together make up a whole feature of the block. These classes can be named by prefixing by block’s class, followed by double underscores. For example: .block_ _element • Modifier- when block or element has some sort of variants in terms of color, size and appearance then the classes further can be expanded. Here, the classes would be prefixed by block’s or element’s class, followed by double hyphens. For example: .block--modifier or .block_ _element-- modifier guptazee.com
  • 6. Real World Example • Let’s take an example of a modal that has been used in an application. • Here, the modal can be considered as a component and it can be targeted by using a class at the block level, say .modal. • Now, a modal can have few common elements like a header, a body and a footer. • So, the modal header can have a class .modal_ _header, its body can have .modal_ _body and its footer element can be named as .modal_ _footer. These three elements are the basic elements of a modal. • Further, a modal can be sized as full-screen, mid-sized or a smaller one. Hence, we can have three variants of the modal. So, its classes can be written as .modal--full, .modal--mid, and .modal--small • There are also chances that its element can have some variants like header can be in black color or body contents are centrally aligned and footer is disable. Now, the classes for these elements can be written as .modal_ _header--black, .modal_ _body--center and .modal_ _footer-- disable. • In this way, you can see that the classes defined above are relevant to a single component and that is a .modal. guptazee.com
  • 7. Few More Instances • A button can also be a component. e.g. .button • It can also be have size and color variants. e.g. .button- -small, .button- - large • It can be primary and secondary. e.g. .button- -primary, .button- - secondary • It can also have elements like header and label. e.g. .button_ _header, .button_ _text guptazee.com
  • 8. Summary • This is how BEM methodology works. By following this naming convention, one can easily make his CSS scalable, maintainable, and reusable. • It also helps to reduce specificity of a selector. • Since, each components are independent blocks. Hence, it can be re-used easily without thinking of code mess-ups. • As says, comments are must thing. One should write as much comments as he feels it should be. It helps other coders to understand your mindset and strategies. • At last not the least, BEM is not exceptional you can use conventions of your own as well. But, it should be in the same way as BEM says, then only one can be benefitted. I am really thankful for your valuable time. guptazee.com