Why I use the BEM naming convention for my CSS

  Рет қаралды 213,467

Kevin Powell

Kevin Powell

Күн бұрын

Пікірлер: 446
@KevinPowell
@KevinPowell 6 жыл бұрын
What's your opinion on BEM? And if you use another one, which one do you use?
@AliAkbar-vo3te
@AliAkbar-vo3te 6 жыл бұрын
If I use BEM, first, I won't be using it every where around my html, second, I would use it in combination with sass.
@techtipsuk
@techtipsuk 6 жыл бұрын
BEM for me
@LorenHelgeson
@LorenHelgeson 6 жыл бұрын
Never heard of it, but I could get used to it. Since how far back has this been a standard?
@KevinPowell
@KevinPowell 6 жыл бұрын
Initial commit to their GitHub repo has in 2014. Not sure when it really took off though
@dvdrtrgn
@dvdrtrgn 6 жыл бұрын
to me it looks overwrought. i haven’t tried it because it seems to work against the cascade that makes css powerful. but i admit i just can’t get past the verbose selector naming.
@JamesMartinBass
@JamesMartinBass 6 жыл бұрын
I've struggled with how to best organize my CSS so the parent/child relationships are clear. This looks really promising. Thanks for explaining it so clearly.
@jarynzr
@jarynzr 6 жыл бұрын
important note that when using BEM make sure that you already got the actual mockup of the design. You have to properly identify each component first
@mattcroat
@mattcroat 6 жыл бұрын
I just started enforcing this the other day. I didn't like it at first but I got used to it and now I'm a fan.
@ozzyfromspace
@ozzyfromspace 3 жыл бұрын
I was coding a React SPA last night and finally had the mobile layout done, but realized that I hadn't thought about how to modify my grids for tablets and desktop. The thought of making poorly organized edits for this drove me nuts, so I went on a search and found BEM. I'm excited to try it. Scrapping my work and starting again, as many times as it takes to do a good job. Nice video Kevin, it was highly informative!
@kamaboko1
@kamaboko1 6 жыл бұрын
BEM is awesome. BEM and SCSS is a great combination.
@ne9835
@ne9835 4 жыл бұрын
right!!!!
@Rogue_Art
@Rogue_Art 3 жыл бұрын
BEM + SCSS makes styling websites super fun
@jmcbade2960
@jmcbade2960 2 жыл бұрын
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. :)
@busyrand
@busyrand 5 жыл бұрын
I just started working on projects for clients and saw this in the wild. I'm happy to have seen things previous to encountering it. It makes much more sense after having to deal with it for a while without understanding what was going on.
@LovePeaceLightCore
@LovePeaceLightCore 6 ай бұрын
I LOVE looking at a stylesheet that follows the BEM convention, its SO clean.
@H4U-14
@H4U-14 Жыл бұрын
I have learnt so much in the past two weeks. Thanks Kevin. HTML, CSS, Mother, Child, SASS, BEM... 😀 So much yet to learn!
@Ah-you-know
@Ah-you-know Жыл бұрын
"... 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.
@tbinyt
@tbinyt 2 жыл бұрын
I learn so much from your videos. I am about 80% through the Conqering Responsive Layout course (it's free guys!! FREE!!). I really appreciate your knowledge and time. Thank you!!!
@leonardoromero7398
@leonardoromero7398 3 жыл бұрын
I'm enrolled in my first programming bootcamp but I can't stop coming to your channel for clarification on almost every topic so thank you for that! You rock!!
@jonathandavis8599
@jonathandavis8599 2 жыл бұрын
and this is for free, bootcamps are shit.
@MrJoefinisher
@MrJoefinisher 6 жыл бұрын
Never seen of CSS naming conventions like this. This is awesome. Thanks so much for posting.
@daniamsalem
@daniamsalem 4 жыл бұрын
I've been reading up on BEM/SCSS while on your Conquering Responsive Layouts course and the one thing I was worried about was how deeply nested the rules get when compiled. However, when you toggled to "compiled css" in CodePen it all became clear. I will totally be implementing BEM this week.
@maxfate9006
@maxfate9006 5 жыл бұрын
I started BEM. It super easy to organise the css. Scss with bem means awesome
@mattcroat
@mattcroat 6 жыл бұрын
I just got into enforcing this the other day. I didn't like it at first but I got used to it and now I'm a fan.
@apphacker
@apphacker 6 жыл бұрын
I like how you're flexible about strictness. Real world sometimes requires some thought, not mindlessly following rules. I really like BEM though!
@SystemXX93
@SystemXX93 5 жыл бұрын
You've got my respect and subscription due to this amazing course. Will watch what's coming next
@KevinPowell
@KevinPowell 5 жыл бұрын
Welcome aboard!
@CarsonSuite
@CarsonSuite 6 жыл бұрын
Lol didn't know that this was actually called somthing but I've been doing this for years! I just love keeping it organized less is more!
@garrystewart376
@garrystewart376 10 ай бұрын
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
@omarshishani5899
@omarshishani5899 Жыл бұрын
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.
@bibibobs
@bibibobs 6 жыл бұрын
I think BEM is the best naming convention, it avoids most scoping problems and is focused on components :).
@rafay773
@rafay773 6 жыл бұрын
"I need to check this BEM thing out ... lets see if Kevin has something on the topic" -- He uploaded a video on BEM just hours ago. Lucky me. Thank you !
@josvelema2362
@josvelema2362 3 жыл бұрын
Thnx for triggering me to get into BEM and SCSS . In your other video's you use it all the time but i never got to see a use case . Using the & operator makes total sense ! Also the specificity thing is nothing to worry about except that it is contagious ;) I noticed that with 'justify-content' you break it up like 'just i fy con tent' and applying that technique does not work for specificity but i just misspell it in my head to get the pronunciation better; like : 'spes-sifi city ' . Don't worry about it for the rest it's kinda cute ;)
@chrismachabee3128
@chrismachabee3128 5 жыл бұрын
Nice Friday video, I'm learning Sass and BEM and you just stitched them together very nicely. Thank you.
@dogpaws7312
@dogpaws7312 6 жыл бұрын
Hello Kevin! I'm a newcomer and been catching up on your videos and I'm really learning quite a lot! I really enjoy watching the from-scratch videos as I can see how things come together and have been using a lot of code into my web dev class I'm taking. Would you consider doing more videos like those? It's really fun to see how a full site can come about from a few lines of code. Thank you for all you do and look forward to more content from you!
@KevinPowell
@KevinPowell 6 жыл бұрын
I'll have another one at one point, but they are really long to put together. So yes, there will be more of them coming... but it might be awhile :\
@tonimaunde
@tonimaunde 3 жыл бұрын
LOL the backtracking at 4:01 is glorious. Thanks for the laugh and knowledge, Kevin.
@johntrent018
@johntrent018 3 жыл бұрын
I know the vid has been done 2y ago but personally I discovered OOCSS and I can say that combined to SASS and SMACSS it's definitely changing how you work with Front-End. I'd say that MVC model is to a website what SMACSS is to CSS. I'm struggling to set it all and change my old messy coding habits but I can directly see effects of OOCSS on code comprehension
@arnobchowdhury9641
@arnobchowdhury9641 6 жыл бұрын
I thought I can pronounce ‘specificity’ until I heard you pronounce it. Now I am having trouble too. Haha
@KevinPowell
@KevinPowell 6 жыл бұрын
Haha, I hope that I didn't rub off on you in a bad way here, lol.
@Victor_Marius
@Victor_Marius 3 жыл бұрын
Specifi - city
@Knards
@Knards 6 жыл бұрын
I love SMACSS, but its very easy to use BEM within that code. Especially with SASS "&" as you said
@FedorTroitsky
@FedorTroitsky 5 жыл бұрын
For the people that think that `.crad.light` `.card h2.title` approach is simpler and more readable: There are several issues with the 'BEMless' approach, that BEM can fix. 1. If you mix your block classes on one DOM node you will have a trouble to distinguish modifiers: `display-item card dark` (is it .display-item.dark or .card.dark?) 2. You will have trouble to overwrite styles with parent selector, because child selector and combined selector has the same specificity level. So you will have to use more specific selectors. 3. Usually it's a bad practice to use DOM nodes as a selector, because you might want to change to or use background image instead of . The idea BEM is promoting is that you should use cascade only if needed, so your styles structure is mainly flat. This allows to combine and nest blocks in DOM easily without making lot's of adjustments to styles. You should read BEM FAQ getbem.com/faq/ it's quite accessible.
@facundocorradini
@facundocorradini 6 жыл бұрын
saw the link in twitter, rushed to watch you said specificicicity. It makes the video SO much better :p
@KevinPowell
@KevinPowell 6 жыл бұрын
hahaha, I should make myself a shirt that says 'specificicicity' on it :P
@tttella
@tttella 6 жыл бұрын
All your minds will be blown when you try styled components instead. So much easier, actually scoped, and much more beautiful
@tttella
@tttella 6 жыл бұрын
CSS < SCSS < BEM < ABEM < CSS in JS
@KevinPowell
@KevinPowell 6 жыл бұрын
I like the concept, but for a lot of my viewers, they're new (or new-ish) to HTML and CSS, and struggle or don't even know JS, so that might be a hard sell, lol. I'm also not personally a fan of CSS in JS. It's not a hill that I would die on... and it depends on a few things... and I know it has advantages, and maybe it's because I'm stubborn, but I just can't get on board personally. If someone asked me if they should adopt it, I wouldn't say 'no' though. More complicated than that.
@tttella
@tttella 6 жыл бұрын
@@KevinPowell That makes sense. As an aside, if you use styled components it's identical to scss, so it's not really that different. The only difference is you're putting it in a js file instead of a css file so you get the same syntax with the benefits of a full programming language. Not to mention you also usually get the benefit of automatic above the fold css which is kind of a pain / tricky usually.
@AbdulMannan-jz7zm
@AbdulMannan-jz7zm 4 жыл бұрын
I was just listening at 1.5X speed and specificity sounded perfect at that speed :)
@SteveT__001
@SteveT__001 3 жыл бұрын
He talks at 1.5x speed so that was 3 x speed ;)
@thecoderabbi
@thecoderabbi 2 жыл бұрын
Thanks Kevin!
@TheCocoaDaddy
@TheCocoaDaddy 3 жыл бұрын
Neat! What I've done is use a class for the 'common' styles and use either another class OR an ID selector to define the unique styles. So, using the 'card' example in this video, I would have a 'card' class with the base styles and have either #light/#dark for the light/dark cards or have .light/.dark classes. I had never heard of BEM until now. Thanks for the info!
@soymuymuy
@soymuymuy 3 жыл бұрын
Hey there. You might like to know it's not valid mark up to have multiple elements on a page with the same id so be careful with that #light #dark idea!
@TheCocoaDaddy
@TheCocoaDaddy 3 жыл бұрын
@@soymuymuy Hi! Thanks for the message. Yes, I'm aware of that. In the case of multiple elements needing to be "light" or "dark", I would use classes. If there's only ONE element that needed to be "light" and one that needed to be "dark", I would use the ID (or I might still use a class). :)
Жыл бұрын
Merry Christmas! Thank You for Your very useful and helpful episodes!
@paoloose
@paoloose 2 жыл бұрын
I dont know how I survived all this time without that
@marshwiggleme
@marshwiggleme 3 жыл бұрын
I didn't even know of BEM or OOCSS until I kept getting in my own way in the responsive layouts course, and looked at other peoples code that i noticed would combine/reuse names. I really still don't know anything about naming conventions or nesting so it would be great to see more.
@gehlwaz
@gehlwaz 5 жыл бұрын
Thanks a lot for this tutorial, super simple explanation to get me started in less than 5 mins! Keep it up.
@facundocorradini
@facundocorradini 6 жыл бұрын
You know I love Five Minute Fridays, but really got the feeling BEM deserved a full-length video to better showcase the many, many issues it prevents.
@KevinPowell
@KevinPowell 6 жыл бұрын
I had to heavily edit this one, so I think you may be right. Probably worth revisiting later on, specially to address some of the comments some people are leaving about why they don't like it.
@iFayding
@iFayding 6 жыл бұрын
I would really appreciate such a video. As a new coder I'm interested in BEM but also unfamiliar with the scenarios in which it best shows it's worth.
@Piercy0812
@Piercy0812 6 жыл бұрын
honest opinion, if new i wouldn't go down this route too much. I think it would be a struggle in most teams to get this implemented and many existings devs would likely not appreciate it. It could be a cool thing to do if working on your own projects, but make sure you know base CSS as much as you can (SCSS and SASS is easy if you know base CSS). I know if my place employed a new dev, the existing team wouldn't appreciate starting to see BEM in places. It makes it harder for more senior developers to help out with newbies if things dont fit in with whats already around. Thats not to say dont use this, just at the start it might not be the best idea to dig too far into it. (just to add some credit to this that im not a complete random dumbass from the net.. im 10 years a developer and currently leading a team of 6)
@KevinPowell
@KevinPowell 6 жыл бұрын
Michael, I'd never advocate for a new person to come into a team and start using something that they aren't using. That would simply cause problems, like you mentioned. This is something a team would have to decide on together, and I don't think they need to use BEM, but simply have a naming convension to follow, then when a new person comes in, whatever they use should be explained to them, and they should be expected to follow how everyone else works.
@facundocorradini
@facundocorradini 6 жыл бұрын
@@Piercy0812 BEM is an industry standard, and has been for almost a decade. I'm totally with you on that any team needs *an* architecture (whichever one they choose to follow), and newcomers have to follow it. It just so happens that BEM is the CSS architecture of choice for 90% of places, not counting those who go with a CSS in JS approach.
@simeongeorgiev1107
@simeongeorgiev1107 4 жыл бұрын
Thank you for the video! Really brought much light on that topic for me!
@pixelum2023
@pixelum2023 2 жыл бұрын
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. ;-)
@karsyz
@karsyz 3 ай бұрын
Just before I watched this video, I was having trouble saying emissivity. Right there with ya :D
@JonBrookes
@JonBrookes Жыл бұрын
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
@robertclarke4096
@robertclarke4096 2 жыл бұрын
Thanks for this Kevin. Super helpful!
@1fromtibet
@1fromtibet 5 жыл бұрын
Really appreciated if you help us to make another epic about the comparison between different naming conventions as you mentioned in the clip, awesome epics...
@KevinPowell
@KevinPowell 5 жыл бұрын
I don't have a lot of experience with the others, so I'm not sure if I could do the others justice or not.
@1fromtibet
@1fromtibet 5 жыл бұрын
@@KevinPowell no worries, thank you very much for reply at least and I like your clip very much and please keep posting it
@zwiebec78
@zwiebec78 5 жыл бұрын
lol I have been known for saying the word "activity" as "activititty" good vid, learned something today.
@Denvercoder
@Denvercoder 6 жыл бұрын
BEM is cool if you do it. I usually start out will good BEM and finish with .main___item-card__title-dark 😂
@KevinPowell
@KevinPowell 6 жыл бұрын
Lol, I know how you feel. I've figured out some ways to avoid that, which I might make a more in depth video about at one point
@Denvercoder
@Denvercoder 6 жыл бұрын
Kevin Powell I would love to see that.
@JeanPatrickSmith
@JeanPatrickSmith 6 жыл бұрын
@@Denvercoder +1
6 жыл бұрын
Naming things is hard! You could just use .main-card__title--dark
@mdibbets
@mdibbets 6 жыл бұрын
This reminds me of php before namespaces. class magento_store_display_cart_item extends magento_general_display_item There's a reason namespaces were introduced. Seems those who thought up bem never considered lessens learned from other languages...
@Octopossible
@Octopossible 6 жыл бұрын
I would've just used classes "card dark" and "card light" then my CSS has .card {...} as well as .card.light {...} and .card.dark {...}. I'm not sure what BEM has done for you beyond that, apart from redundant verbosity in the naming conventions. Not only have you addedd -- and __ but you've reused the word card a gajillion times. I don't think that's necessary. SASS really helps with the nesting issues, though, that's for sure.
@DavidNitzscheBell
@DavidNitzscheBell 6 жыл бұрын
I think the reason to call it .card--light instead of creating a simple .light class, is because a generic name like "light" might be appropriate in many places throughout the project and throughout the CSS. If you have light cards, light buttons, etc. you would need some way of distinguishing the different "light" classes so that the right one was used in the right place. The benefit this BEM gives you is the ability to literally copy/paste the CSS for a card into a new project. This .card definition is completely modular. No wrapper class. The CSS is all together, so, easy to move to the next project.
@Octopossible
@Octopossible 6 жыл бұрын
David Nitzsche-Bell CSS for .card.light is distinct!
@DavidNitzscheBell
@DavidNitzscheBell 6 жыл бұрын
@@Octopossible but multi-level CSS selectors goes against the BEM methodology, which tries to keep the CSS file as flat as possible. Again, if you have another element on your page that you also want to be .light, so maybe .section.light, but the styles you want to apply are *in any way* different from the styles applied to .card.light, then you're in a pickle. Having .card--light and .section--light lets you style each one uniquely.
@KevinPowell
@KevinPowell 6 жыл бұрын
.card.light or even .child .selector are distinct, but can cause specificity issues. You'll notice all CSS naming conventions and style guides strongly advocate for class names for everything, and no tag or ID selectors. And Google, which doesn't mind ID selectors, specifically mentions to avoid nested selectors, mainly for performance reasons ( google.github.io/styleguide/htmlcssguide.html#Type_Selectors ) There are issues with BEM, and I understand why some people don't like it, but it, and other conventions, have come about as solutions to problems that come up as projects scale, and from working on teams. If you are working on smaller projects, or are the only person working on it, and it's not a project that's revisted, you may never run into these problems and t hings like BEM seem insane, and sometimes it can be overkill on a small project, but then if that project starts to scale up, the last thing yo uwant to do is have to refactor a ton of code because you start running into issues, or worse, start having to use !important and run into specificity battles all of a suddden.
@michaelwoodruff5752
@michaelwoodruff5752 6 жыл бұрын
Also, the __ means that something is nested, while -- means that something has extra specificity. That difference cant really be described using your card.dark selector. I think this convention is super crisp. I'm going to use it from now on for most projects.
@hopsta
@hopsta 6 жыл бұрын
Really cool system and I love it works well with Sass too. Thanks for the video
@RasmusSchultz
@RasmusSchultz 2 жыл бұрын
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. 🙂
@RasmusSchultz
@RasmusSchultz 2 жыл бұрын
(no doubt conventions can still help with the "human" problems - I'm just wondering if conventions and systems are still necessary to solve any technical problem?)
@jasonsworld333
@jasonsworld333 Жыл бұрын
Nice and short way to go.
@approachingpassive
@approachingpassive 6 жыл бұрын
So I can’t double thumbs up but this is worthy of two. Just had a discussion at work regarding how to organize css. We have a terribly nested set of base templates that is a nightmare to call out. The spe-ci-fi-ci-ty drives me crazy.
@KevinPowell
@KevinPowell 6 жыл бұрын
I almost feel like if I pronouce it properly one day, I'll disappoint everyone :P
@stanleymcomber4844
@stanleymcomber4844 2 жыл бұрын
I actually like this convention, BEM - easy and clean.
@puerquitoDeSatanas
@puerquitoDeSatanas 6 жыл бұрын
BEM is great, but i don't understand why using two and not just one dash and write shorter class names: .card .card_body .card-dark
@KevinPowell
@KevinPowell 6 жыл бұрын
We use one hyphen for spacing, so say something like '.featured-content'. If after this I had '.featured-content-footer' that just looks like a long name for it, whereas 'featured-content--footer' shows me that it's a modifier. It makes it much easier to see, and really hitting the key twice doesn't slow you down.
@DavidNitzscheBell
@DavidNitzscheBell 6 жыл бұрын
@@KevinPowell I tend to use camelCase for my names, so a single dash/underscore could work.
@AnkerPeet
@AnkerPeet 6 жыл бұрын
@@KevinPowell that would've been nice to hear that in video. I wouldn't of known the answer to the question you posed in the title unless I came to this comment.
@JeanPatrickSmith
@JeanPatrickSmith 6 жыл бұрын
@@DavidNitzscheBell blasphemy!
@gwork5615
@gwork5615 6 жыл бұрын
@@JeanPatrickSmith ROFL
@DaggoeNinja
@DaggoeNinja 2 жыл бұрын
Another great tutorial. thx Kevin
@rayskinner4289
@rayskinner4289 6 жыл бұрын
Thanks for that sass nesting shortcut. Good stuff.
@KevinPowell
@KevinPowell 6 жыл бұрын
No problem :)
@andrewenyeart3501
@andrewenyeart3501 3 жыл бұрын
Thanks for the explanation!
@bencrossley4085
@bencrossley4085 6 жыл бұрын
Say 'Specif-y' (long i sound as in the verb). Change the -y into an -i (short i sound). 'Specif-i'. The add 'city'. And hey presto you've got... SPECIF - I - CITY Easier if you just split it into two bits: SPECI - FIC ITY What about 'specific-ness' instead!! PS Great tutorial, as always. Really useful and clear.
@KevinPowell
@KevinPowell 6 жыл бұрын
At this point I think it's just part of my charm, lol. I can say it slowly, over and over, and then say it at a normal speed and my brain malfunctions again.
@muzika5001
@muzika5001 3 жыл бұрын
Thank you for making complicated things simple. Now my code will have more added value, and it will be cleaner. 👍👍👍👍
@dav2288
@dav2288 6 жыл бұрын
I think I will start to use it, I like it a lot. Simple and effective.
@KevinPowell
@KevinPowell 6 жыл бұрын
It can be a little hard at first, knowing how far to go with it. Get's more natural over time.
@freemancity2518
@freemancity2518 3 жыл бұрын
Thank you a lot for your help !
@phamthang6558
@phamthang6558 2 жыл бұрын
it's very helpfull. thank you for explaining, it's so clear
@BitFrosty
@BitFrosty 6 жыл бұрын
Quick, clear and simple - that's a like
@tech-nomade
@tech-nomade 9 ай бұрын
This is gold
@objectObject212
@objectObject212 5 жыл бұрын
Thanks for video, nice and quick explanation 😉
@taariqq
@taariqq 4 жыл бұрын
Valuable information about -- out in the field.
@kolyaevdokimov
@kolyaevdokimov Жыл бұрын
thanks, Kevin
@procrastinator24
@procrastinator24 2 жыл бұрын
awesome video, thanks so much!
@longtran12345678
@longtran12345678 6 жыл бұрын
like this video a lot, especially preventing unnecessary nest(s)
@igeyarugu9575
@igeyarugu9575 10 ай бұрын
Thank you for sharing
@ahummbrahmasmi
@ahummbrahmasmi 5 жыл бұрын
Much needed stuff, Thanks a lot for BEM
@skyzane2735
@skyzane2735 7 ай бұрын
Do you have a video on Getting Started with css on a new project? Like giving the resets, defining :root variables everything without using sass?
@elliemay1748
@elliemay1748 6 жыл бұрын
This takes care of some of the nesting issues but you’re still nested. Now if card-dark needs a different body text color you have to overwrite .card__body, for example, with nesting within card-dark. Nevertheless I think it’s a good compromise to avoid having to re-write css for things like headers and paragraphs. But... if you use a css framework, it will have default styling for everything, and you’ll still have to overwrite. This is why I avoid using anything other than divs unless absolutely necessary for SEO. If it doesn’t have a use case for SEO, use a div or span.
@KevinPowell
@KevinPowell 6 жыл бұрын
Was I using things other than divs or spans, except where needed, in my example? Good point about the .card__body. I'm going to look at some options for dealing with that in future videos, so we can avoid things like having .card__body--light and .card__body--dark and crap like that, which is annoying.
@jgarzarebel2631
@jgarzarebel2631 2 жыл бұрын
Thank you! 🌟❤🥰
@Fliteska
@Fliteska 5 жыл бұрын
I try to use BEM, but I've started trying utility first lately. A lot of people at work don't like it but that's fine they like to do classes like bigRedText
@KevinPowell
@KevinPowell 5 жыл бұрын
While you might disagree, if you're working with a team and they've adopted a way to work, I'd say you need to suck it up and do the same. You could try and argue your point in a very respectful and well thought out way that it might be a good idea to switch though! But if you're working with people on a project, having different naming systems defeats the purpose of having a naming system.
@Fliteska
@Fliteska 5 жыл бұрын
@@KevinPowell had a chat with the team, they are going to try out BEM, I explained to them the different issues with setting up class names and avoiding throwing in a random class
@ricssilvaDB1
@ricssilvaDB1 Жыл бұрын
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!!! :)
@aditiakolkar6905
@aditiakolkar6905 6 жыл бұрын
Thanks K.P. for such a good video. Also the links provided below video are very useful. I always see your videos. I learn a lot from them + some new things gets to know. I'm happy to subscribed your video.
@KevinPowell
@KevinPowell 6 жыл бұрын
I'm glad that you enjoyed the video and found the links useful Aditi! Thanks for the sub :D
@maxmaxmaxmaxmaxmaxmaxmaxmax1
@maxmaxmaxmaxmaxmaxmaxmaxmax1 3 жыл бұрын
"This is a Friday meaning we're going to be doing this in under five minutes" [Looks at video length: 7:02] Keep up the good content :)
@deeplybrown
@deeplybrown 5 жыл бұрын
"I know I did too many cicicities, but that's just how I say it 'cause I can't pronounce it." LOL
@ne9835
@ne9835 3 жыл бұрын
Lol
@nivoset
@nivoset 4 жыл бұрын
I think it is more useful on static sites. When being compiled I think it doesnt matter as much. And it is even less if using shadow dom overall. I dont mind you using it personally or for videos. And if the site you write is large and complex but not compiled in other ways. It is useful.
@Shkkmj6868
@Shkkmj6868 Жыл бұрын
Nice video. Thanks a lot.
@faridshokri4034
@faridshokri4034 5 жыл бұрын
I just watched ur video and I can't help myself not to think how much u look like Hayden Szeto Nice content btw 👍
@SamCrowetheCreativeCrowe
@SamCrowetheCreativeCrowe 2 жыл бұрын
This is really cool.
@graaam101
@graaam101 6 жыл бұрын
I think everyone is missing the point in the comments section as to why this is advocated (even if I don't like it personally) Let's say you have: .card{} .card.light{} .big{} .big.light{} and at that point you want to create a div with class="card light big" At this point the .light class will then be applied twice with unique rules being additive and rules that clash being over-ridden by the latest declared class definition. This is why the convention has it's merits on a gigantic project as you can guarantee zero collisions. Personally I think it is over-engineering the problem as the extra effort typing all the repeated names for the occasional collision that could be remedied with .big.light.card is not worth it, but then again I have only worked in small to mid sized teams so control is probably easier at that size.
@robertzeurunkl8401
@robertzeurunkl8401 6 жыл бұрын
I guess I'm just too new to this.... But.... All you have is a "card" class that defines CSS common to both cards, and then additional classes for light and dark cards, that addresses the differences. What does this have to do with double dashes, and double underscores, other than naming conventions that say "Hey, I'm a subclass of the 'card' class?"
@KevinPowell
@KevinPowell 6 жыл бұрын
Nothing at all, that's exactly what the dashes an underscores denote. It makes it so that, later on if you're references your CSS, you know if something is a subclass, or a modifier class, or the block itself instantly, without even needing to read the name.
@guersomfalcon7544
@guersomfalcon7544 4 жыл бұрын
Considering that to use the '&' symbol you don't need to use double hyphens or underscores, why not use only a hyphen and an underscore?
@stevebennetts5161
@stevebennetts5161 4 жыл бұрын
Great Video thank you!
@JesusFerVid94
@JesusFerVid94 Жыл бұрын
BEM really helps having cleaner and well-organized code. BTW, what font are you using on VSCode?
@gualaguala
@gualaguala 6 жыл бұрын
Bem is good for non compoonent based development. New frameworks are very isolated and have possibility to use per component based css. I would recommend something like SuitCSS methodology. BEM is old...
@Luggruff
@Luggruff 5 жыл бұрын
Nice video! I already use the same method, only difference is that I adapt the following syntax: card, cardLight, cardBody etc. Maybe your way is is specific and useful for SASS? I don't use it. Tried it (SASS) and it was just an annoyance with the compiler to be honest. Maybe one day it will be less of a hassle and a built in standard for CSS itself.
@KevinPowell
@KevinPowell 5 жыл бұрын
the double underscore works super well with Sass, which is one of the reasons I do like it. your method works great as well, same idea and less keystrokes :D - some people prefer keeping camel case to JS, but honestly I don't see an issue with it!
@insanityrodax8621
@insanityrodax8621 6 жыл бұрын
What about making other video about the complexity of nested elements? It would be really cool, since everyone has a problem when the project starts to get bigger.
@KevinPowell
@KevinPowell 6 жыл бұрын
One of the reasons I like BEM, I find it deals with that nicely. I'll see if I can't come up with an example to use for a future video.
@chemedev
@chemedev 4 жыл бұрын
Hi, I'd like to see your approach for using SMACCS or Atomic CSS !
@KevinPowell
@KevinPowell 4 жыл бұрын
I use BEM most of the time, which is why I made a video on it :D I might do one on Tailwind one of these days though (though that's more of a library than a naming convention)
@georgesmith3022
@georgesmith3022 6 жыл бұрын
nice video kevin, short and to the point
@matthewfelgate
@matthewfelgate 6 жыл бұрын
Nice video. Although if 'light' is the default for card then you would only need an additional .card--dark {...} class I think. It think with BEM then .card should work without a modifier.
@SaleKnezevic
@SaleKnezevic 5 жыл бұрын
Great stuff (did i just cleaned small dust of it?)
@milindkhadse556
@milindkhadse556 20 күн бұрын
helpful information thank you
@not_importan
@not_importan 2 жыл бұрын
Thanks bunches, really useful
7 ways to deal with CSS
6:23
Fireship
Рет қаралды 1,1 МЛН
How you can simplify your CSS with :is()
9:20
Kevin Powell
Рет қаралды 335 М.
When mom gets home, but you're in rollerblades.
00:40
Daniel LaBelle
Рет қаралды 138 МЛН
КОГДА К БАТЕ ПРИШЕЛ ДРУГ😂#shorts
00:59
BATEK_OFFICIAL
Рет қаралды 7 МЛН
BEM Class Naming Convention in Webflow
12:07
Timothy Ricks
Рет қаралды 26 М.
Organizing CSS with OOCSS, SMACSS, and BEM - Matt Stauffer
37:55
Gainesville Front-end Developers Meetup
Рет қаралды 78 М.
БЭМ методология за 10 минут | Основы для начинающих
10:01
Александр Ламков — Friendly Frontend
Рет қаралды 21 М.
Learn CSS BEM (and avoid these common mistakes)
15:36
Dmitry Mayorov
Рет қаралды 8 М.
Using CSS custom properties like this is a waste
16:12
Kevin Powell
Рет қаралды 178 М.
min(), max(), and clamp() are CSS magic!
18:12
Kevin Powell
Рет қаралды 300 М.
BEM in 6 minutes - CSS Methodology 2024
6:22
Blue Script
Рет қаралды 35 М.
You Probably Need BEM CSS in Your Life (Tutorial)
18:47
DesignCourse
Рет қаралды 165 М.
5 CSS mistakes that I see way too often
19:03
Kevin Powell
Рет қаралды 360 М.
CSS is getting better, but Sass is still relevant
18:42
Kevin Powell
Рет қаралды 31 М.
When mom gets home, but you're in rollerblades.
00:40
Daniel LaBelle
Рет қаралды 138 МЛН