💡
My Docs
BlogLinkedin
WEB_DEV_JOB_SEARCH
WEB_DEV_JOB_SEARCH
  • Home
  • 🏡Home
  • 🗺️Navigation
  • 📥Useful Downloads
  • TO DO
    • Meetings:
    • Take Home Assignments
  • Jobs To Apply To
  • 🛠️Skills
    • 🍢My Stack
    • E-Engineering
    • SQL / PSQL
  • 📋Filling Out Forms
  • 📖Resources
    • Linkedin Cheat Shee
    • Job Search Advice
    • Orientation:
    • Links
    • Running List Of MISC Resources:
    • ❄️Cold Outreach Generator
  • Profiles
  • Linkedin
  • Examples
  • Resume
    • Resume
      • Certificate (Lambda)
      • Examples
      • Advice
      • Dice
      • Linkedin Resume
      • Indeed Resume
  • Applications
    • 🖱️TRACKING_APPLICATIONS
    • Amazon
  • Applications & Job Postings
    • Job Boards
      • More Job Boards
    • 📮Postings:
      • Avid / Pro Tools
      • Amazon
      • My Applications
        • Application Info
        • In Progress
      • First Round Of Applications
      • Jobs To Keep Track Of
      • Recommended Jobs
  • Cover Letter
    • Cover Letter
      • CV-Guidance
    • More Advice
      • Practice Problems:
    • Example
    • Example Of Developer Bio
    • Old Engineering Cover Letter
  • Portfolio
    • 💾Git Repo
    • 🖼️Portfolio
  • 📈Slack&Lambda
    • 📺Recordings
    • 🧑‍🤝‍🧑🧑🤝🧑 🧑🤝🧑 🧑People
  • Aux-Resources
    • Youtube
    • 👨‍🏫👨🏫 👨🏫 👨Guidance
  • 🖋️Interview Prep
    • INTERVIEW
    • 👨‍💻👨💻 👨💻 👨💻 👨💻 👨💻 👨💻 👨💻 Leetcode
      • 37-Essential-Js-Questions
      • 📈Rubric
    • Resources
      • List of List
      • Cheat-Sheet
    • Cheat-Sheet-Raw
    • General Advice & Tips
      • Website Checklist
      • Phone Interview Advice
    • Overview
      • Data-Structures Q & A
    • Web Dev Interview Questions
      • FULL-STACK DEVELOPER INTERVIEW QUESTIONS AND ANSWERS
    • ⁉️Interview Questions.
      • cross-site scripting attack (XSS) and how do you prevent it?
      • What are refs in React? When should they be used?
      • virtual DOM and why is it used in libraries/frameworks?
      • What does the following code evaluate to?
      • What is the this keyword and how does it work?
      • What are landmark roles and how can they be useful?
      • What is the difference between lexical scoping and dynamic scoping?
      • What is the difference between null and undefined?
      • What is CSS BEM?
      • What is HTML5 Web Storage? Explain localStorage and sessionStorage.
      • How can you avoid callback hells?
      • What is functional programming?
      • useful example of one?
      • What is an async function?
      • What is the difference between the equality operators == and ===?
      • use-strict
      • sync-vs-async
      • null-vs-undefined
      • promises
      • accessibility-tree
        • imperative-vs-declarative
      • bem
      • cors
      • alt-attribute
    • Qualitative Questions
      • Cheat Sheets
        • Python-VS-JS Cheat Sheet
        • 🐍Python
      • React Interview
        • React Questions:
      • Front End Questions
    • 🧮DS_ALGO Practice:
      • Algorithms
      • Exampes
      • DS_ALGO_NOTES
        • The queue data structure (JS)(PY)
    • Behavorial
      • Python Subpage
      • DS_&_ALGO_STUDY_GUIDE
      • Intro 2 Graphs:
      • Graphs
        • Graph (py)
      • Free Code Camp
      • Types Of Data Structures
      • Arrays
      • Page 2
      • 🥅Hash Tables
    • FANG PREP (medium article)
    • ⏱️More Practice:
    • 300 React Q & A's
      • 💸React Tips
    • Redux
    • 🛕Examples
      • Representing A Graph:
      • Anagrams & Big O
        • Python Performance
        • Strongly Connected Graph
      • Gists
    • Common Knowledge Questions
  • Tutorials
    • Custom Outreach Message Generator
      • Common Questions
      • Self Introduction
  • Technical Interview Tutorial
  • Job Boards
    • 📋Job Boards
      • Less Promising Job Boards
      • LIST OF BOARDS
  • Networking
    • 🗓️Events
  • MISC
    • Articles To Read
    • Job Search Images
  • Notes
    • Interview Navigation
    • Notes
    • CSS Interview Prep Quiz
  • 🖨️Interviewing
    • General
    • Inspiration
    • Front End Interview
    • Common Questions
  • Networking
    • Networking
      • a/A Email List
    • Page 1
  • 📓ARCHIVE
    • Archive
      • ❇️Slack Announcements
    • Projects
Powered by GitBook
On this page
  • Answer
  • Good to hear
  • Additional links

Was this helpful?

Edit on GitHub
  1. Interview Prep
  2. Interview Questions.

What is CSS BEM?

Answer

The BEM methodology is a naming convention for CSS classes in order to keep CSS more maintainable by defining namespaces to solve scoping issues. BEM stands for Block Element Modifier which is an explanation for its structure. A Block is a standalone component that is reusable across projects and acts as a "namespace" for sub components (Elements). Modifiers are used as flags when a Block or Element is in a certain state or is different in structure or style.

/* block component */
.block {
}

/* element */
.block__element {
}

/* modifier */
.block__element--modifier {
}

Here is an example with the class names on markup:

<nav class="navbar">
  <a href="/" class="navbar__link navbar__link--active"></a>
  <a href="/" class="navbar__link"></a>
  <a href="/" class="navbar__link"></a>
</nav>

In this case, navbar is the Block, navbar__link is an Element that makes no sense outside of the navbar component, and navbar__link--active is a Modifier that indicates a different state for the navbar__link Element.

Since Modifiers are verbose, many opt to use is-* flags instead as modifiers.

<a href="/" class="navbar__link is-active"></a>

These must be chained to the Element and never alone however, or there will be scope issues.

.navbar__link.is-active {
}

Good to hear

  • Alternative solutions to scope issues like CSS-in-JS

Additional links

PreviousWhat is the difference between null and undefined?NextWhat is HTML5 Web Storage? Explain localStorage and sessionStorage.

Last updated 3 years ago

Was this helpful?

🖋️
⁉️
Writing clean and maintainable CSS