SlideShare a Scribd company logo
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

More Related Content

Similar to Let's BEM together

BEM It! for Brandwatch
BEM It! for BrandwatchBEM It! for Brandwatch
BEM It! for Brandwatch
Max Shirshin
 
BEM it! Introduction to BEM
BEM it! Introduction to BEMBEM it! Introduction to BEM
BEM it! Introduction to BEM
Varya 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 development
Vittorio Vittori
 
BEM it! Introduction to BEM methodology
BEM it! Introduction to BEM methodologyBEM it! Introduction to BEM methodology
BEM it! Introduction to BEM methodology
Varya Stepanova
 
HTML and CSS Coding Standards
HTML and CSS Coding StandardsHTML and CSS Coding Standards
HTML and CSS Coding Standards
Saajan Maharjan
 
Intro to OOCSS Workshop
Intro to OOCSS WorkshopIntro to OOCSS Workshop
Intro to OOCSS Workshop
Julie Cameron
 
Drupalese 101: DrupalCamp Atlanta 2014
Drupalese 101: DrupalCamp Atlanta 2014Drupalese 101: DrupalCamp Atlanta 2014
Drupalese 101: DrupalCamp Atlanta 2014
Annika Garbers
 
Bootstrap Paragraphs for Drupal 8
Bootstrap Paragraphs for Drupal 8Bootstrap Paragraphs for Drupal 8
Bootstrap Paragraphs for Drupal 8
Jim Birch
 
BEM methodology overview
BEM methodology overviewBEM methodology overview
BEM methodology overview
Oleksii Prohonnyi
 
Wordpress workflow for an agency world
Wordpress workflow for an agency worldWordpress workflow for an agency world
Wordpress workflow for an agency world
Chris Lowe
 
BEM it!
BEM it!BEM it!
BEM it!
Max Shirshin
 
DHTML
DHTMLDHTML
What is Modular CSS?
What is Modular CSS?What is Modular CSS?
What is Modular CSS?
Scott Vandehey
 
Responsive Design and Bootstrap
Responsive Design  and BootstrapResponsive Design  and Bootstrap
Responsive Design and Bootstrap
MahmoudOHassouna
 
Vanilla Forums Theme Guide
Vanilla Forums Theme GuideVanilla Forums Theme Guide
Vanilla Forums Theme Guide
Vanilla Forums
 
full-site-editing-theme-presentation.pptx
full-site-editing-theme-presentation.pptxfull-site-editing-theme-presentation.pptx
full-site-editing-theme-presentation.pptx
Plasterdog 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 - Gutenberg
Evan 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 - Gutenberg
Mickey Mellen
 
How to customise Joomla
How to customise JoomlaHow to customise Joomla
How to customise Joomla
Tim Plummer
 

Similar to 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
 

Recently uploaded

Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024
Globus
 
Cyaniclab : Software Development Agency Portfolio.pdf
Cyaniclab : Software Development Agency Portfolio.pdfCyaniclab : Software Development Agency Portfolio.pdf
Cyaniclab : Software Development Agency Portfolio.pdf
Cyanic lab
 
Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024
Globus
 
2024 RoOUG Security model for the cloud.pptx
2024 RoOUG Security model for the cloud.pptx2024 RoOUG Security model for the cloud.pptx
2024 RoOUG Security model for the cloud.pptx
Georgi Kodinov
 
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
Globus
 
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Globus
 
Enhancing Research Orchestration Capabilities at ORNL.pdf
Enhancing Research Orchestration Capabilities at ORNL.pdfEnhancing Research Orchestration Capabilities at ORNL.pdf
Enhancing Research Orchestration Capabilities at ORNL.pdf
Globus
 
Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus
 
Navigating the Metaverse: A Journey into Virtual Evolution"
Navigating the Metaverse: A Journey into Virtual Evolution"Navigating the Metaverse: A Journey into Virtual Evolution"
Navigating the Metaverse: A Journey into Virtual Evolution"
Donna Lenk
 
top nidhi software solution freedownload
top nidhi software solution freedownloadtop nidhi software solution freedownload
top nidhi software solution freedownload
vrstrong314
 
Cracking the code review at SpringIO 2024
Cracking the code review at SpringIO 2024Cracking the code review at SpringIO 2024
Cracking the code review at SpringIO 2024
Paco van Beckhoven
 
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, BetterWebinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
XfilesPro
 
Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604
Fermin Galan
 
Prosigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology SolutionsProsigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology Solutions
Prosigns
 
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdfDominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
AMB-Review
 
Graphic Design Crash Course for beginners
Graphic Design Crash Course for beginnersGraphic Design Crash Course for beginners
Graphic Design Crash Course for beginners
e20449
 
GlobusWorld 2024 Opening Keynote session
GlobusWorld 2024 Opening Keynote sessionGlobusWorld 2024 Opening Keynote session
GlobusWorld 2024 Opening Keynote session
Globus
 
Quarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden ExtensionsQuarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden Extensions
Max Andersen
 
First Steps with Globus Compute Multi-User Endpoints
First Steps with Globus Compute Multi-User EndpointsFirst Steps with Globus Compute Multi-User Endpoints
First Steps with Globus Compute Multi-User Endpoints
Globus
 
Using IESVE for Room Loads Analysis - Australia & New Zealand
Using IESVE for Room Loads Analysis - Australia & New ZealandUsing IESVE for Room Loads Analysis - Australia & New Zealand
Using IESVE for Room Loads Analysis - Australia & New Zealand
IES VE
 

Recently uploaded (20)

Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024
 
Cyaniclab : Software Development Agency Portfolio.pdf
Cyaniclab : Software Development Agency Portfolio.pdfCyaniclab : Software Development Agency Portfolio.pdf
Cyaniclab : Software Development Agency Portfolio.pdf
 
Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024
 
2024 RoOUG Security model for the cloud.pptx
2024 RoOUG Security model for the cloud.pptx2024 RoOUG Security model for the cloud.pptx
2024 RoOUG Security model for the cloud.pptx
 
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
 
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
 
Enhancing Research Orchestration Capabilities at ORNL.pdf
Enhancing Research Orchestration Capabilities at ORNL.pdfEnhancing Research Orchestration Capabilities at ORNL.pdf
Enhancing Research Orchestration Capabilities at ORNL.pdf
 
Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024
 
Navigating the Metaverse: A Journey into Virtual Evolution"
Navigating the Metaverse: A Journey into Virtual Evolution"Navigating the Metaverse: A Journey into Virtual Evolution"
Navigating the Metaverse: A Journey into Virtual Evolution"
 
top nidhi software solution freedownload
top nidhi software solution freedownloadtop nidhi software solution freedownload
top nidhi software solution freedownload
 
Cracking the code review at SpringIO 2024
Cracking the code review at SpringIO 2024Cracking the code review at SpringIO 2024
Cracking the code review at SpringIO 2024
 
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, BetterWebinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
 
Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604
 
Prosigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology SolutionsProsigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology Solutions
 
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdfDominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
 
Graphic Design Crash Course for beginners
Graphic Design Crash Course for beginnersGraphic Design Crash Course for beginners
Graphic Design Crash Course for beginners
 
GlobusWorld 2024 Opening Keynote session
GlobusWorld 2024 Opening Keynote sessionGlobusWorld 2024 Opening Keynote session
GlobusWorld 2024 Opening Keynote session
 
Quarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden ExtensionsQuarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden Extensions
 
First Steps with Globus Compute Multi-User Endpoints
First Steps with Globus Compute Multi-User EndpointsFirst Steps with Globus Compute Multi-User Endpoints
First Steps with Globus Compute Multi-User Endpoints
 
Using IESVE for Room Loads Analysis - Australia & New Zealand
Using IESVE for Room Loads Analysis - Australia & New ZealandUsing IESVE for Room Loads Analysis - Australia & New Zealand
Using IESVE for Room Loads Analysis - Australia & New Zealand
 

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