Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
BEM
Search
Felipe Luiz Soares
October 28, 2016
Technology
0
73
BEM
Talk about Block, Elements and Modifiers.
Felipe Luiz Soares
October 28, 2016
Tweet
Share
More Decks by Felipe Luiz Soares
See All by Felipe Luiz Soares
Writing unit tests with Jest using test best practices
felipesoares6
0
180
Comecei uma tarefa e olha no que deu!
felipesoares6
0
53
GraphQL & beyond
felipesoares6
0
56
HTML + CSS
felipesoares6
1
140
THE MEANING OF LIFE FRONT-END USER EXPERIENCE AND EVERYTHING
felipesoares6
0
60
Read-Search-Ask
felipesoares6
1
93
Other Decks in Technology
See All in Technology
Wasmのエコシステムを使った ツール作成方法
askua
0
220
ソースを読むプロセスの例
sat
PRO
15
9.3k
ニッポンの人に知ってもらいたいGISスポット
sakaik
0
170
衛星画像超解像化によって実現する2D, 3D空間情報の即時生成と“AI as a Service”/ Real-time generation spatial data enabled_by satellite image super-resolution
lehupa
0
190
「改善」ってこれでいいんだっけ?
ukigmo_hiro
0
340
Databricks AI/BI Genie の「値ディクショナリー」をAmazonの奥地(S3)まで見に行く
kameitomohiro
1
190
ガバメントクラウド(AWS)へのデータ移行戦略の立て方【虎の巻】 / 20251011 Mitsutosi Matsuo
shift_evolve
PRO
2
200
OpenTelemetry が拡げる Gemini CLI の可観測性
phaya72
1
190
今この時代に技術とどう向き合うべきか
gree_tech
PRO
2
2.1k
やる気のない自分との向き合い方/How to Deal with Your Unmotivated Self
sanogemaru
1
520
Oracle Base Database Service 技術詳細
oracle4engineer
PRO
12
81k
Data Hubグループ 紹介資料
sansan33
PRO
0
2.2k
Featured
See All Featured
Statistics for Hackers
jakevdp
799
220k
Making Projects Easy
brettharned
120
6.4k
Navigating Team Friction
lara
190
15k
Agile that works and the tools we love
rasmusluckow
331
21k
The Language of Interfaces
destraynor
162
25k
Why You Should Never Use an ORM
jnunemaker
PRO
59
9.6k
KATA
mclloyd
PRO
32
15k
Leading Effective Engineering Teams in the AI Era
addyosmani
7
470
The Cost Of JavaScript in 2023
addyosmani
55
9k
How STYLIGHT went responsive
nonsquared
100
5.8k
GraphQLとの向き合い方2022年版
quramy
49
14k
A designer walks into a library…
pauljervisheath
209
24k
Transcript
BEM Blocks, Elements and Modifiers Felipe Soares
FELIPE SOARES Apreciador de abacaxis github.com/felipesoares6 speakerdeck.com/felipesoares6 Front-end Developer Estagiário
na Codeminer 42
None
Bem is Blocks Elements and Modifiers
Bem is Is a component-based approach to web development. The
idea behind it is to divide the user interface into independent blocks. Understand the relationship between the HTML and CSS in a given project.
BLACK blocs
Blocks
Blocks A functionally independent page component that can be reused.
In HTML, blocks are represented by the class attribute.
Blocks The block name describes its purpose ("What is it?"
— menu or button).
Blocks can be nested in each other. You can have
any number of nesting levels. Blocks
<header class="header"> <div class="logo"></div> <form class="search-form"></form> </header>
Elements
Elements A composite part of a block that can't be
used separately from it.
Elements The element name describes its purpose ("What is this?"
— item, text, etc.) The structure of an element's full name is block-name__element-name.
Elements can be nested inside each other. You can have
any number of nesting levels. Elements An element is always part of a block, not another element.
<form class="search-form"> <input class="search-form__input"> <button class="search-form__button"> Search </button> </form>
Modifiers
Modifiers An entity that defines the appearance, state, or behavior
of a block or element.
Modifiers The modifier name describes its appearance ("What size?" or
"Which theme?" and so on — theme_islands), state ("How is it different from the others?" — disabled, focused), behavior ("How does it behave?" or "How does it respond to the user?" — such as directions_left-top).
From the BEM perspective, a modifier can't be used in
isolation from the modified block or element. Modifiers A modifier should change the appearance, behavior, or state of the entity, not replace it.
<form class="search-form search- form--focused"> <input class="search-form__input"> <button class=" search-form__button--disabled"> Search
</button> </form>
Should I create a block or an element?
If a section of code might be reused and it
doesn't depend on other page components being implemented, you should create a block.
If the section of code can't be used separately without
the parent entity (the block), an element is usually created.
SASS WAY
.search-form { background-color: red; &__button { margin: 20px; &--disabled {
display: none; } } } .form { display: flex; &--focused { color: black; } }
That’s all folks! flw vlw gretchen https://en.bem.info/ https://css-tricks.com/bem-101/ http://getbem.com/introduction/ https://unsplash.com/@pineapple