Products
Features
YouTube Video Summarizer
Summarize YouTube videos
Web & PDF Highlighter
Highlight web pages & PDFs
Chat with PDF
Ask any PDF questions with AI
Ask AI Clone
Chat with your highlights & memories
Audio Transcriber
Transcribe audio files to text
Glasp Reader
Read and highlight articles
Kindle Highlight Export
Export your Kindle highlights
Idea Hatch
Hatch ideas from your highlights
Integrations
Obsidian Plugin
Notion Integration
Pocket Integration
Instapaper Integration
Medium Integration
Readwise Integration
Snipd Integration
Hypothesis Integration
Apps & Extensions
Chrome Extension
Safari Extension
Edge Add-ons
Firefox Add-ons
iOS App
Android App
Discover
Discover
Ideas
Discover new ideas and insights
Articles
Curated articles and insights
Books
Book recommendations by great minds
Posts
Essays and notes from readers
Quotes
Inspiring quotes collection
Videos
Curated videos and summaries
Explore Glasp
Glasp Newsletter
Weekly insights and updates
Glasp Talk
Interview series with great minds
Glasp Blog
Latest news and articles
Glasp Use Cases
Learn how others use Glasp
Build & Support
Glasp API
Access Glasp's API for developers
MCP Connector
Connect Glasp to Claude & ChatGPT
Community
Glasp Reddit Community
Students
Student discount and benefits
FAQs
Frequently Asked Questions
AboutPricing
DashboardLog inSign up

How to Use BEM for CSS Class Naming with Examples

2.7K views
•
April 21, 2021
by
Web Dev Cody
YouTube video player
How to Use BEM for CSS Class Naming with Examples

TL;DR

BEM (Block Element Modifier) is a CSS methodology that structures class names to prevent style conflicts in large applications. By dividing class names into blocks, elements, and modifiers, BEM ensures unique naming and easier styling management, significantly improving the scalability and maintainability of your code.

Transcript

hey everyone welcome back to another web dev junkie video hope you guys are having a great day so in this video i want to kind of talk about what bem is and how we are using it in a project to basically style our components so if you don't know what this is it's basically just a a methodology of naming your html elements okay so if you've used html... Read More

Key Insights

  • 🥳 BEM is structured around three clear parts: block, element, and modifier, which helps maintain code readability.
  • 🌥️ Consistent naming conventions provided by BEM can significantly improve collaboration among developers on large projects.
  • 🕸️ BEM addresses issues common in CSS like style conflicts, thus improving the scalability of web applications.
  • 🏃 Learning and understanding the nuances of BEM can save time and effort in debugging and maintaining styles in the long run.
  • ❓ Developers are encouraged to utilize resources like BEM validators to ensure adherence to proper styling conventions.
  • 🎮 The video offers an approachable overview to help beginners grasp the essentials of BEM methodology quickly.
  • 🦡 Understanding BEM can help developers break bad habits related to arbitrary class naming and CSS organization.

Install to Summarize YouTube Videos and Get Transcripts

Explore YouTube Video Summarizer or Get YouTube Transcript Extractor

Questions & Answers

Q: What does the acronym BEM stand for in CSS?

BEM stands for Block Element Modifier. It is a naming convention that breaks down class names into three parts: the block (a standalone component), the element (a part of the block), and the modifier (a variant of the block or element). This structure improves clarity and reduces chances of styling conflicts, especially in larger codebases.

Q: How does BEM help in styling large applications?

BEM helps in styling large applications by imposing a systematic naming convention that minimizes class name duplication. By defining classes in a clear hierarchy and using unique names, developers can style components without the risk of overriding each other’s CSS rules, thus maintaining consistency and simplifying debugging.

Q: Can you explain how to implement modifiers in BEM?

Modifiers in BEM are appended to block or element names to signify variations. For instance, if you have a block named 'button', you could create modifiers like 'button--large' or 'button--small'. This naming strategy clearly indicates alterations in style or behavior while following the BEM structure, hence maintaining clarity.

Q: What challenges might you face if you don't use BEM in your projects?

Without using BEM, developers are likely to encounter issues such as class name duplication, styling conflicts, and difficulties in debugging. As projects become more complex and team collaboration increases, it can lead to styles affecting multiple components unpredictably, making maintenance cumbersome and error-prone.

Q: Why is it important to validate BEM code?

Validating BEM code is crucial to ensure adherence to the methodology, which promotes correct structure and naming conventions. It helps identify improper usage, such as incorrect targeting of nested elements, which can lead to potential conflicts and maintenance difficulties. Using a validator ensures that your codebase remains manageable and clean.

Q: What are some common mistakes developers make when implementing BEM?

Common mistakes include using generic class names that don’t follow the BEM convention, improperly nesting classes, and neglecting to use modifiers correctly. For example, directly targeting elements like images without proper naming conventions, such as appending --image to a block name, can lead to non-BEM compliant structures and unclear styles.

Summary & Key Takeaways

  • BEM, or Block Element Modifier, is a CSS naming convention designed to reduce style conflicts in large applications by clearly defining class names into a structured format.

  • The methodology divides class names into blocks, elements, and modifiers, promoting unique naming and preventing style overlap, facilitating easier debugging as applications grow.

  • The video discusses practical examples of implementing BEM in code, addressing common pitfalls, and suggesting resources for further study to help developers effectively adopt this approach.


Read in Other Languages (beta)

English

Share This Summary 📚

Summarize YouTube Videos and Get Video Transcripts with 1-Click

Download browser extensions on:

Try YouTube Summary with ChatGPT & Claude or YouTube Transcript Generator

Explore More Summaries from Web Dev Cody 📚

I got my first DDoS (and what you can do to help prevent it) thumbnail
I got my first DDoS (and what you can do to help prevent it)
Web Dev Cody
How I setup pagination in my Next.js app (with Drizzle ORM) thumbnail
How I setup pagination in my Next.js app (with Drizzle ORM)
Web Dev Cody
Live Coding a Shopping Cart using React thumbnail
Live Coding a Shopping Cart using React
Web Dev Cody
How I'm doing authentication on my simple Go app (with Fiber) thumbnail
How I'm doing authentication on my simple Go app (with Fiber)
Web Dev Cody
How Does the MacBook Air M1 Compare for Coding? thumbnail
How Does the MacBook Air M1 Compare for Coding?
Web Dev Cody

Summarize YouTube Videos and Get Video Transcripts with 1-Click

Download browser extensions on:

Try YouTube Summary with ChatGPT & Claude or YouTube Transcript Generator

Apps & Extensions

  • Chrome Extension
  • Safari Extension
  • Edge Add-ons
  • Firefox Add-ons
  • iOS App
  • Android App

Key Features

  • YouTube Video Summarizer
  • Web & PDF Summarizer
  • Web & PDF Highlighter
  • Chat with PDF
  • Ask AI Clone
  • Audio Transcriber
  • Glasp Reader
  • Kindle Highlight Export
  • Idea Hatch

Integrations

  • Obsidian Plugin
  • Notion Integration
  • Pocket Integration
  • Instapaper Integration
  • Medium Integration
  • Readwise Integration
  • Snipd Integration
  • Hypothesis Integration

More Features

  • APIs
  • MCP Connector
  • Blog & Post
  • Embed Links
  • Image Highlight
  • Personality Test
  • Quote Shots

Company

  • About us
  • Blog
  • Community
  • FAQs
  • Job Board
  • Newsletter
  • Pricing
Terms

•

Privacy

•

Guidelines

© 2026 Glasp Inc. All rights reserved.