Why I use the BEM naming convention for my CSS

Why I use the BEM naming convention for my CSS

Kevin Powell

5 лет назад

208,037 Просмотров

Ссылки и html тэги не поддерживаются


Комментарии:

@KevinPowell
@KevinPowell - 09.11.2018 20:19

What's your opinion on BEM? And if you use another one, which one do you use?

Ответить
@tech-nomad-de
@tech-nomad-de - 10.02.2024 18:11

This is gold

Ответить
@igeyarugu9575
@igeyarugu9575 - 28.12.2023 04:07

Thank you for sharing

Ответить
@nomadshiba
@nomadshiba - 22.12.2023 14:25

for anyone looking at this in 2023 or later.
this is outdated.
scoped CSS exists now

Ответить
@garrystewart376
@garrystewart376 - 21.12.2023 11:53

Can’t thank you enough for all the things I’ve learned from you. I still feel like a novice when I watch your work, but slowly it’s seeping into my head 😂 A loyal fan of your vids

Ответить
@rokoszoczek25
@rokoszoczek25 - 09.12.2023 13:05

thanks!

Ответить
@ricssilvaDB1
@ricssilvaDB1 - 10.11.2023 21:10

And 5 years later, on a Friday, here I am... learning about BEM! LOL

Well... if this is not LONG TAIL CONTENT, I don't know what it is!!! :)

Ответить
@Zoe-rn4md
@Zoe-rn4md - 26.07.2023 17:27

Hi! It's been four years since you posted this, are you still using BEM?

Ответить
@webdeveloper4742
@webdeveloper4742 - 23.07.2023 21:20

Can you say dead-pools chicachetaa

Ответить
@itiremiroglu7646
@itiremiroglu7646 - 20.06.2023 19:16

how i link .scss files?? <link rel="stylesheet" href="style.scss"/> is not correct?? p.s.: i'm on vscode not codepen.

Ответить
@mkline1669
@mkline1669 - 01.06.2023 06:44

Love it

Ответить
@rafa6536
@rafa6536 - 30.05.2023 18:18

I don't use BEM anymore. It looks ugly and there is too much writing with those names. Instead I use simple names and I combine classes. I think BEM is for someone who don't know about .class1.class2 notation :)

Ответить
@omarshishani5899
@omarshishani5899 - 25.05.2023 05:02

Nice, thanks. I love BEM. I learned some more tips from this video, like your use of &__body in Sass. I was glad to hear you talk about how you aren't totally strict with BEM, but you use it as your foundation. I use BEM as my main naming convention for CSS.

Sometimes I try and implement BEM on existing projects. I feel like this can be a good idea because it still can target components, and give a clear name even for components/elements that haven't been totally written in BEM.

However, trying to implement on existing projects does cause specificity issues, which is of course what we are trying to avoid by using BEM in the first place.

Ответить
@Shkkmj6868
@Shkkmj6868 - 15.05.2023 14:50

Nice video. Thanks a lot.

Ответить
@jasonsworld333
@jasonsworld333 - 02.05.2023 19:05

Nice and short way to go.

Ответить
@kolyaevdokimov
@kolyaevdokimov - 02.05.2023 17:10

thanks, Kevin

Ответить
@KommaAchtKommaEins
@KommaAchtKommaEins - 30.04.2023 15:44

After wasting a week with trying and hating Tailwind (which I consider "class vomit"), BEM is a mental vacation.

Ответить
@H4U-14
@H4U-14 - 16.04.2023 12:31

I have learnt so much in the past two weeks. Thanks Kevin. HTML, CSS, Mother, Child, SASS, BEM... 😀 So much yet to learn!

Ответить
@argothiel
@argothiel - 29.03.2023 14:39

What kind of specificity problems would be with nesting in larger projects? What's the problem with having:
.card .image{
}
instead of
.card__image{
}

Ответить
@JonBrookes
@JonBrookes - 12.03.2023 16:38

specificificity😀 neither can I

I think BEM is a great idea and to me how you explain it also very easy to understand and reason with

having classes for things rather than nesting things using css to target stuff like you say I can see how that could turn into a world of pain on large layouts

is this not in principle what other approaches like tailwind etc are doing I sort of guess ? So they are using isolated classes to apply things that can be sort of reused / applied and have each obvious class names ?

I really like your explanation of sass and &__ pattern to get the 'parent' name - very clever stuff

Ответить
@glatocha
@glatocha - 05.03.2023 13:27

Is sass still a thing in 2023? I mean somehow I do not use it much. Same question about BEM, because I did not see until your responsive design challenge

Ответить
@markcook8516
@markcook8516 - 02.03.2023 19:51

In regard to "parent/child" naming convention, I like staying with the name container. Parent 1 = container01, Parent 2 = container02. Then each generation uses the alphabet. First child of parent 1: container01a, second child container01b ... grandchildren would be another letter: container01aa, container01ab.

Not a fan of "hero"

Ответить
@Ah-you-know
@Ah-you-know - 27.02.2023 18:17

"... literally having a class on everything to specif... you know, actually properly select it." KP with the offensive rebound.

Thanks for the concise explanations, Kevin. I initially tried creating my own naming system, but I might as well create my own language and speak to myself if I go down that path.

Ответить
@JesusFerVid94
@JesusFerVid94 - 14.02.2023 12:54

BEM really helps having cleaner and well-organized code. BTW, what font are you using on VSCode?

Ответить
@JanisGrinvalds
@JanisGrinvalds - 25.12.2022 19:06

Merry Christmas! Thank You for Your very useful and helpful episodes!

Ответить
@arigrafik
@arigrafik - 11.12.2022 08:17

Hi Kevin! It would be great if you add subtitles to this video. It tells me they are not available. Thank you very much!

Ответить
@MasharipovSaidbek
@MasharipovSaidbek - 28.11.2022 10:01

hi!

Ответить
@bartoszsowa5140
@bartoszsowa5140 - 25.10.2022 19:24

If there was no CCTV, no one would ever have problems pronouncing specificity

Ответить
@cmidi275
@cmidi275 - 26.09.2022 16:39

hi

Ответить
@jmcbade2960
@jmcbade2960 - 19.09.2022 09:08

This is a really good explanation and I really appreciate the discipline and outcome to present this in the 5 min duration. Any definition standard such as BEM could easily be overly granular if taken too far. I think the key is using BEM enough that if you have to go back and make changes they work well on a global basis and having to hunt down and tweak too many specific details is where the balance is most productive.

I would like to see more of these Kevin. :)

Ответить
@SamCrowetheCreativeCrowe
@SamCrowetheCreativeCrowe - 02.09.2022 01:49

This is really cool.

Ответить
@end-me-please
@end-me-please - 30.08.2022 18:25

Thanks you

Ответить
@pixelum2023
@pixelum2023 - 27.08.2022 16:30

Interesting concept. I'm currently redoing my wife's business site, going from WP+Divi to pure HTML+CSS. And I've run into issues keeping my CSS organised and avoiding styling conflicts between different pages. BEM might be the solution. BTW, you forgot to change the title for the dark card. ;-)

Ответить
@DaggoeNinja
@DaggoeNinja - 13.08.2022 15:36

Another great tutorial. thx Kevin

Ответить
@jgarzarebel2631
@jgarzarebel2631 - 05.08.2022 06:46

Thank you! 🌟❤🥰

Ответить
@whyfoo
@whyfoo - 28.07.2022 13:24

thank u for this

Ответить
@medra001
@medra001 - 06.06.2022 21:44

its not working for me

Ответить
@Hugos68
@Hugos68 - 06.06.2022 21:13

OOP in css

Ответить
@stanleymcomber4844
@stanleymcomber4844 - 12.05.2022 18:29

I actually like this convention, BEM - easy and clean.

Ответить
@stanleymcomber4844
@stanleymcomber4844 - 12.05.2022 18:27

You are missing pronouncing the F. SpeciFicity 😚🤓

Ответить
@phamthang6558
@phamthang6558 - 09.05.2022 17:21

it's very helpfull. thank you for explaining, it's so clear

Ответить
@RasmusSchultz
@RasmusSchultz - 03.05.2022 09:02

4 years on, and I've been wondering - do we still really have a specificity problem? You can use :where() to select the child tags of a component. And more recently, you can explicitly organize components and modifiers into hierarchies using cascade layers - which also makes me wonder about the future of things like utility-first. Do we still need any of those things? I mean, you can literally just load e.g. bootstrap into a layer and override anything you want in a "theme" layer - the cascade doesn't seem to cause any problems anymore. Can we go back to just using CSS the way it was intended now? Instead of inventing all these complex patterns and systems? Would love to hear your thoughts on this topic in a video. 🙂

Ответить
@SahilBhosale08
@SahilBhosale08 - 17.04.2022 11:11

Hi

Ответить
@emekaorji9170
@emekaorji9170 - 05.04.2022 10:23

Thanks Kevin!

Ответить
@aking0309
@aking0309 - 28.03.2022 01:01

No worries man! You should hear me try to say “rural” lol

Ответить
@flowerofash4439
@flowerofash4439 - 04.02.2022 18:31

spesisissty

Ответить
@procrastinator24
@procrastinator24 - 01.02.2022 15:15

awesome video, thanks so much!

Ответить
@dzbanek3017
@dzbanek3017 - 28.01.2022 12:44

I still don't understand why "card_image" instead of "card__image" isn't enough, and "card_title" instead of "card__title", "card_body" instead of "card__body" and so on.

Ответить
@robertclarke4096
@robertclarke4096 - 27.01.2022 18:46

Thanks for this Kevin. Super helpful!

Ответить
@paoloose
@paoloose - 20.01.2022 22:49

I dont know how I survived all this time without that

Ответить