You Probably Need BEM CSS in Your Life (Tutorial)

Поділитися
Вставка
  • Опубліковано 30 вер 2024

КОМЕНТАРІ • 365

  • @DesignCourse
    @DesignCourse  4 роки тому +120

    Enjoooy?? Subby subby!

    • @GammaWraith
      @GammaWraith 4 роки тому +6

      I did.. Coursy? Coursy?

    • @lucianoramirez6525
      @lucianoramirez6525 4 роки тому

      as always so useful, but I have a question not entirely related. How could one get around having to get the back-end done yourself, and instead just have e.g. an email submission form made with an API? Could that be possible? If so how? Because I actually built a sort of fully-blown html and css project with different urls but my goal for this website is for it to get people submit their email to apply and stuff, but that would require some kind of back-end. Would it not? Hope I explained myself clear enough, sorry if not. Thanks again!

    • @juraev0056
      @juraev0056 4 роки тому

      @@lucianoramirez6525 Yes it does require some backend if you want people to sign up to apply for something. If you just want a contact form that sends you a user message from your website, its very easy to do.

    • @xrishi20
      @xrishi20 4 роки тому

      It's live sass compiler, not compilation i guess 🤭

    • @Saaztube
      @Saaztube 4 роки тому

      Had to subscribe. Thanks.

  • @yvonniie
    @yvonniie 3 роки тому +79

    I want a Part 2 where you go more in depth with a bigger project!

  • @CODINGVENTURE
    @CODINGVENTURE 4 роки тому +211

    I'm mad he never noticed that he added a class to the end of the list item tag

    • @1997matthew
      @1997matthew 4 роки тому +5

      It's the Auto Rename Tag plugin that's doing that

    • @CODINGVENTURE
      @CODINGVENTURE 4 роки тому +10

      @@1997matthew I know I'm just mad he didn't notice lol

    • @local9
      @local9 4 роки тому +25

      You got mad at that... I got mad at calling Underscores (_) as Hyphens (-) and Hyphens as Dashes >.

    • @physx_naraka
      @physx_naraka 4 роки тому +5

      I was about to raise my hand and tell him that, thought it was a real-life lecture .

    • @estoriassurreais3434
      @estoriassurreais3434 4 роки тому

      @@1997matthew thanks

  • @akashbond862
    @akashbond862 4 роки тому +39

    Came here after watching Kevin Powell's video on BEM. There he had said "specificicity", and here Gary says "specifity". Guess Kevin stole Gary's "ci".

  • @JohnVenters
    @JohnVenters 4 роки тому +79

    Sorry to be that guy, but it's "specificity"

    • @DesignCourse
      @DesignCourse  4 роки тому +59

      I can't even say that. And I want to punch whoever came up with the term.

    • @JohnVenters
      @JohnVenters 4 роки тому +8

      @@DesignCourse Haha, no worries, mate! Great tutorial regardless. Thanks for taking the time to make it for us!

    • @dertuman
      @dertuman 4 роки тому

      Haha was just about to post this

    • @svendbentjensen5512
      @svendbentjensen5512 4 роки тому

      Actually it's speficitify, everyone knows that

    • @harrypehkonen
      @harrypehkonen 4 роки тому +2

      @@DesignCourse "Specificness" -- much easier to say. It's even in the dictionary! Apparently it has a slightly different meaning, though... although *I* think it's more accurate (i.e. more specific to what we are using it for) ;D

  • @BenRangel
    @BenRangel 4 роки тому +36

    One piece of advice is: don’t forget utility-classes just cause you use BEM! A ”hidden” class makes more senese than having a ton of modifier classes that do the same thing, like ”card-hidden” and ”article-hidden”
    Only use BEM for unique styles and not common ones.
    You can combine BEM and utility classes, no need to go 100% in a single direction.
    doing ”card card-large hidden” is fine

  • @crooker2
    @crooker2 4 роки тому +6

    Specificity... Pronounced: spes-ih-FISS-city (5 syllables)
    :)
    Good video. I don't use BEM currently, but I'm going to play with it.

  • @acidspark
    @acidspark 4 роки тому +23

    11:40 "__" is underscore underscore, double underscore or dunder, not hyphen hyphen you did it repeatedly, at some point everything just became hyphen hyphen.

    • @local9
      @local9 4 роки тому

      It ground my gears to much.

  • @EvaLasta
    @EvaLasta 3 роки тому +5

    Man you got such a unique vocabulary haha
    1:02 "specifity"
    3:14 "complexitness"
    I think you mean specificity and complexity lol I love your videos btw Im just playing around.

    • @rand0mtv660
      @rand0mtv660 3 роки тому +1

      The second was was him saying "a little bit more complex than this".

  • @_ric
    @_ric 4 роки тому +1

    Too clunky, too verbose and (imo) just a solution for a problem created by people who have issues dealing with complex CSS layers. Understanding both HTML5 semantics, CSS pseudo classes and having a good grip on how stylesheets actually cascade (and the weighting of the rules) effectively negate the use of BEM.
    Maintenance you say? Ease of readability you say? For the former, who are you hiring? Devs who should know this stuff or people who can match up names to classes? As for the latter, it really doesn't make it any more readable. Any large project (and BEM is aimed at those) becomes a complete mess when facing repeated nested BEM css classes.

    • @sashabeep
      @sashabeep 4 роки тому

      AFAIK BEM was invented to use for pages that builds from some json-like blocks [{"block":"card","elements":{"item":.........}}]
      HTML markup for this blocks was never writen by hand, so it was another one template builder based on file structure. CSS for each block could be separated. Main idea was to use any combination of blocks on the page. Which, of course, the big deal for large projects. Sadly, some of webdevs tries to use this convention in much simplier projects. Also, using BEM without BEM stack is pretty useless IMO. Here you can learn about BEM stack en.bem.info/technologies/classic/bemjson/
      And, yes, cascade is the one letter from CSS abbreviature, but in the very large projects it can cause some glitches, so hard separated styles works.

  • @BenRangel
    @BenRangel Рік тому +3

    I've used BEM for many years.
    Modifiers are great and truly provides a nice way of stating a clear intention that this element has a shared base style and a variant that overrides or adds a few things.
    But the block__element concept is less useful. It's fine in tiny flat components that you don't change a lot.
    But in larger things the double underscore often has to be moved deeper down and feels useless.
    You begin with footer__menu but as that menu gets more and more children you rename it to footer-menu so can have children like footer-menu__user and footer-menu__faq
    If this renaming happens multiple times, or the dom tree for the footer is quite deep then you end up just forgetting which nodes have the block__element thing and which just use dashes.
    At which point I usually go "screw it, let's use single dashes all the way" and I never end up regretting it.
    I still use BEM on small isolated components though.

  • @JensAndersenGuitarist
    @JensAndersenGuitarist 2 роки тому +1

    It is Spe-ci-fi-ci-ty ;-) And why arent you using semantic elements in HTML? Like a section or an article for the card? It is supposed to be an element that can stand alone and therefore it should be an article or a section for each card? I know that there is not a title/heading in this example, but anyways? And why is the picture/img not a part of the content element?

  • @howiewang4238
    @howiewang4238 3 роки тому +5

    Thank you for this tutorial. In the beginning, why do we need two underscores for Class name instead of one underscore, which is simpler and more efficient?

  • @zentekvideogames3589
    @zentekvideogames3589 4 роки тому +5

    12:03 Was it necessary to add class="card__item" inside the closing tags as well? Or was it a typo?

  • @ioshaven436
    @ioshaven436 4 роки тому +3

    BEM in 2020? I thought everyone moved on to utility classes.
    BEM is too verbose and difficult to read.
    BEM is only good for eliminating CSS specificity.
    But if you have problems with CSS specificity you probably can't write CSS in the first place.
    TL;DR use Tailwind over BEM

  • @georgemallard4120
    @georgemallard4120 4 роки тому +4

    I am a CSS newbie. The way he showed BEM using the $ helped me understand the cascade in CSS. Thanks!

  • @rafaellerescapone
    @rafaellerescapone 4 роки тому +6

    if i wasnt already using React+Styled Components to deal with such issues, this looks like an amazing system to solve such problems in a practical and DX friendly way

  • @devKazuto
    @devKazuto 4 роки тому +32

    I'm not a fan of BEM. I prefer using utility classes instead of --modifier. Most IDE don't have a problem selecting "card-header" on double click, but will struggle with "card__header". Having an arbitrary long class name will also increase file size. We're removing line breaks and spaces on minification, but 30 letters long classes are fine.

    • @BenRangel
      @BenRangel 4 роки тому +1

      Kazu: which IDE? i thought most had a hotkey to select by free text search.
      I use vscode and I use cmd+d to select any string by free text search

    • @BenRangel
      @BenRangel 4 роки тому +7

      What do you mean by arbitrarily long? In BEM the idea is you can only have a single level: card__header is ok but card__header__title or card__header__title__icon is banned

    • @devKazuto
      @devKazuto 4 роки тому +2

      @@BenRangel I'm talking about double click text selecting, not hotkey. Some don't see cohesion of a string like "abc--xyz".
      Having class="button button--state-success" creates a larger filesize in HTML than class="button success". In CSS it's the same. .button-state-success are more characters than .button.success and therefor results in a larger filesize.

    • @kootahaitoo
      @kootahaitoo 4 роки тому +7

      @Angelo Stevens yeah file size is like the last reason i would worry when dealing with BEM and CSS

    • @alexsmith-rs6zq
      @alexsmith-rs6zq 3 роки тому +2

      Why not both? I’ve recently started using a combination of utility classes for shared styles and BEM for unique styling. It seams to be working well so far.

  • @ujjawalchatterjee
    @ujjawalchatterjee 4 роки тому +4

    Why can't we consider the list as an individual block and the items as it's element?

    • @sashabeep
      @sashabeep 4 роки тому

      You can put the block into another block - it's allowed by convention

    • @ujjawalchatterjee
      @ujjawalchatterjee 4 роки тому

      But, in this case, what is it? Block or element?

  • @Dextergec413
    @Dextergec413 4 роки тому +1

    I think everyone pronounces specificity differently lol

  • @PoetikSage
    @PoetikSage 2 роки тому +1

    I don't care if I'm doing large project or small, I always use BEM. (that's different thing I don't get large projects)

  • @Ahmad-lc1ln
    @Ahmad-lc1ln 2 роки тому +1

    It's useless, using SASS is better.

  • @alex_chugaev
    @alex_chugaev 4 роки тому +10

    I'm so happy Angular has styles isolation mechanism and I don't need to use BEM anymore :D

    • @Zach2825
      @Zach2825 4 роки тому +1

      Vue has that too. It is so convenient

    • @diablo.the.cheater
      @diablo.the.cheater 4 роки тому +5

      @Angelo Stevens overkill is a feature not a bug

    • @ShadiMuhammad
      @ShadiMuhammad 4 роки тому

      @@diablo.the.cheater 😂😂

    • @etmargallo
      @etmargallo 4 роки тому

      Do you guys mean “scoped”?

  • @deniskazakov4584
    @deniskazakov4584 4 роки тому +3

    Card__content accidentally is not a block?

  • @WyzrdCat
    @WyzrdCat 4 роки тому +1

    I really dislike this method because it's very redundant. I don't like this method much because it is overly verbose. I'm not really a fan because with BEM you say the same thing over and over again.

    • @christianmartinez2179
      @christianmartinez2179 4 роки тому +1

      BEM Is trying to solve a problem that doesn't even exist
      Te solution is to use the CSS specificity
      BEM is like trying to replicate what already exists and works flawlessly

    • @WyzrdCat
      @WyzrdCat 4 роки тому +1

      @@christianmartinez2179 I agree. It's not hard to target things specifically. You don't need extra identifiers for that. Using a single "active" class on various elements is, in every single way, superior, to BEM method of having "element" and "element__button" and "element__button.active". In most cases you don't need the element OR the element button class name, but even if you do, you don't need . You can do ALL the same things, the code is FAR more semantic, and you are saving SIGNIFICANT FILE SIZE by having shorter class names! People worry so much about image compression, then they go and make fatass CSS files that are the size of 20 images all in one request because they have 20 extra class names on every rule, they are using duplicated styles for 30 different objects that all have the exact same styles "because BEM" .... and 50,000 styles that aren't used anywhere on the site because of all the hideous frameworks they keep building on top of! Not to mention the extra size in the pages themselves! Everything adds up!

  • @IcedCupcakes
    @IcedCupcakes 10 місяців тому

    "specifity. I can never say it right. SPECIFITY! there we go!" DEAD xD great video though!!

  • @coolworx
    @coolworx Рік тому

    What's the point of doubling up on the underscores and the hyphens?
    Wouldn't card_button-active tell you the same information (what it's for) as card__button--active?

  • @SampathLokuge
    @SampathLokuge 4 роки тому

    BEM is destroying a concept of the template, prohibiting usage of CSS functions and possibilities, shoving developer to hardcode. Source: hackernoon.com/bem-should-not-exist-6414005765d6

  • @rockboris666
    @rockboris666 3 роки тому

    You should probably change the title to "You Probably need BEM CSS in Your Life (if you're using a preprocessor) (Tutorial)". None of this makes sense with vanilla CSS where the same can be accomplished with _a lot_ less verbose class names.

  • @liquidsnake6879
    @liquidsnake6879 3 роки тому

    People always do such basic examples lol, the problem with BEM is when you have multiple components, when you got very large complex components and then people get confused as to what is and isn't an element, especially problematic when people use "wrapper" like "card__wrapper" and then underneath that ungodly things like "card__wrapper__image" or just define classes like
    "card__wrapper card-wrapper" and then underneath "card-wrapper__image"

  • @sashabeep
    @sashabeep 4 роки тому

    Everybody forgetting about that BEM is for auto-generated markup that nobody code by hand. When i see BEM in simple website templates it cause only smile - this dude wasted a LOT of time to do that. Also, in my opinion, the BEM team are snobs who think they have some wonderful knowledge. Fun fact: it took several years to drop the b_ prefix for 'blocks' definition. Everybody can invent own css naming convention. Column width and color classes in Bootstrap (and every other css framework), for example, is modifiers too, so, there is no rocket science at all.

  • @lxc3909
    @lxc3909 4 роки тому

    I cannot take the redundancies of BEM. CSS selectors make this possible without re-re-repeating the block name, and re-repeating the element name, just to add a modifier class. Ugh-ly.

  • @firespittnkitten
    @firespittnkitten 4 роки тому

    I don't see why this is necessary. In your card example, you could use the class name "picture" and target that via CSS with .card > .picture. BEM is just a solution in search of a problem.

  • @Meleeman011
    @Meleeman011 3 роки тому +1

    i really hate BEM. but thank you, i needed this to pass a front-end coding test

  • @jasonleelawlight
    @jasonleelawlight 2 роки тому

    I have used BEM in one previous company project, not a big fan of it. I like modular css/scss much better.

  • @alamesawikanningkaton5028
    @alamesawikanningkaton5028 2 роки тому

    That was clear... but a little bit confusing if we want to use isolated component or block to another block. We can not override style from unrelated block.
    for example, we want to use .btn block inside .card block. Let say that the button inside .card block have different style. So how we deal with it?

  • @MultiMrAsd
    @MultiMrAsd 4 роки тому

    BEM is great, but please stop using it in combination with CSS modules. Just leave the Block out and name it EM. I see a lot of juniors doing this and it really hurts readability

  • @DavidOtto82
    @DavidOtto82 3 роки тому

    If you dont know how to use the C in CSS, BEM really shines ;D No, srsly: Dont use BEM, unless you are writing plugins

  • @jenninexus
    @jenninexus 4 роки тому +3

    This is my new favorite channel :-D Thanks for all the great knowledge

  • @EpicphoneGamer
    @EpicphoneGamer 2 роки тому

    Important question. What is that green guitar in the background? Are these EMG pickups?

  • @sumitwadhwa8823
    @sumitwadhwa8823 4 роки тому

    shouldn't card__item be card__list__item..? it's little confusing when it nested

  • @techtipsuk
    @techtipsuk 4 роки тому +1

    It’s not so much semantics, it’s modularity of it that’s important.

  • @danielmancera9867
    @danielmancera9867 3 роки тому

    but the UL could not be considered as a block itself? card-list and the the items, card-list__item?

  • @cswithabdullah2638
    @cswithabdullah2638 3 роки тому

    My underscore is not displaying. When I type underscore it is not displayed instead multiple items get selected.
    Anyone has solution?

  • @AlexMNet
    @AlexMNet 2 роки тому

    I spy with my little eye a Kemper Toaster!

  • @galickidigital
    @galickidigital 3 роки тому

    How do you name basic website sections with text and image on the right? Just curious

  • @Vittokm
    @Vittokm Рік тому

    Very very good! was trying to understand this before but only now I understand :)

  • @lennart5845
    @lennart5845 4 роки тому +4

    I’ve been using it just because I saw that JetBrains has it on the webpage. Now I see why I’m doing it

    • @notkamui9749
      @notkamui9749 4 роки тому +2

      I like the fact that you follow JetBrains :)

    • @AndiRadyKurniawan
      @AndiRadyKurniawan 4 роки тому

      Why is that? What's the benefit?

    • @lennart5845
      @lennart5845 4 роки тому +1

      Andi Rady Kurniawan if you’re using scss, which will definitely help you a lot, this Bem makes it easier. You can type .menu and in scss the „&“ character selects it again but you can add something. So for example if you have a list in your menu which has the class „menu__list“ you can just type in the menu css: &__list (.menu__list). And that with several items. It just helps you a lot and organizes everything

  • @eritert
    @eritert 4 роки тому +1

    Why not just nest in sass and leave out the duplicate text in classes?

  • @user-gs3pt1uf1g
    @user-gs3pt1uf1g 3 роки тому

    Coming from a big project, one important lesson learnt: don't abuse Sass/SCSS, keep it to bare minimum. Reason? Trying to resolve a high priority production defect with a huge SPA codebase, it doesn't help to have .block { ...; &__element{... &--modifier{...}} rulsets: it very hard to find the original rule definition in source code, since in the browser you'll see generated version. The lesson learned, in order to be able to quickly find a rule, write entire selector by hand, don't leave it up to SCSS preprocessor. One thing is to write confusing Sass code to impress junior female developers on your team, and another thing to debug prod issue under pressure and a lot of stress. KISS.

    • @GamingTSH
      @GamingTSH 2 роки тому

      🙏❤️ua-cam.com/video/lmIwYLFYZ9U/v-deo.html❤️🙏

  • @alexanonymous5823
    @alexanonymous5823 3 роки тому

    thanks for BEM explanation=))

  • @AuxonSound
    @AuxonSound 4 роки тому

    if we use example .avatar in whole website with 'modifer' ex. .avatar.small how in BEM its looks like? Do I need create so much code for all blocks by separeted, example card__avatar, userslist__avatar, footer__avatar with same code, but in selfs code placed (i cant grab all and display by comma coz its destroy look of code design)? its nonsense in my opinion.

  • @haveboard
    @haveboard 2 роки тому

    *specificity
    ua-cam.com/video/er1JEDuPbZQ/v-deo.html

  • @kzar123
    @kzar123 4 роки тому

    Great video. Subscribing now

  • @DrDrovel
    @DrDrovel 3 роки тому

    Next episode. Why BEM suck..

  • @iUmerFarooq
    @iUmerFarooq 4 роки тому +1

    Who want to see the studio tour?

  • @Gigusx
    @Gigusx 4 роки тому +2

    I got into TailwindCSS before getting interested in BEM, so I never really ended up needing it. A useful video nonetheless for a quick overview!

    • @Gigusx
      @Gigusx 4 роки тому

      @Library Content Yeah, me as well! The nesting of SASS makes it all look very clean and easy to modify.

    • @Arttyor
      @Arttyor 4 роки тому

      Tailwind is framework tho, this is just methology

    • @Gigusx
      @Gigusx 4 роки тому

      @@Arttyor That's right, but it removes the necessity for using a naming methodology, at least when you follow the similar process that Adam Wathan (Tailwind's author) does.

  • @olasoderlind5685
    @olasoderlind5685 4 роки тому

    Why not .card ,, .card > img ,, .card > h2 ,, .card > p ,, .card > a .. ?
    i anser my own Q --> becose, card__* is unic for sepcial but the "card > img" is for overall styling

    • @sashabeep
      @sashabeep 4 роки тому

      When you will need additional style for particular image .card>img will not allow you to do that due to specifity codepen.io/sashabeep/pen/JjdGWJw

  • @SreekumarMenonPhotography
    @SreekumarMenonPhotography 3 роки тому +1

    specifity ,there we go ! 9:20. :)

  • @maartenvissers283
    @maartenvissers283 3 роки тому

    Can this be combined with bootstrap? How?

  • @soldadopreciso
    @soldadopreciso 3 роки тому

    Thanks pal, what about general approach.

  • @simpleprogramming4671
    @simpleprogramming4671 4 роки тому +1

    Design Course thank you so much for your amazing tutorials. Your Videos are really unique. I have a question, when a block gets very big(when I start a big project it gets really confusing for me how to break it to smaller blocks and elements. does anybody have any suggestions? Thank you all in advance :)

  • @amirfayazi562
    @amirfayazi562 7 місяців тому

    Thanks for such a helpful video

  • @sojibhasan1380
    @sojibhasan1380 3 роки тому

    This video is very helpful especially for me.

  • @parthkumarchaudhary
    @parthkumarchaudhary 4 роки тому +4

    Tutorial on time. Thank you Gery Teacher. :)

  • @bestfacebookcover9348
    @bestfacebookcover9348 4 роки тому

    Terrible. This many underscores...

  • @sanketmane5838
    @sanketmane5838 2 роки тому

    Thank you so much for this tutorial...

  • @Roon3y
    @Roon3y 4 роки тому +1

    Awesome video as always! Quick question, could the ul be card__content__list? and the li card__content__list__item (modifier as card__content__list_item--active)? Would this make it work better with sass/less. Or could something like this be more oocss or smacss?

    • @adm7282
      @adm7282 4 роки тому +2

      If you don't have too many classes I prefer to do "card__list" and "card__list-item". It's shorter and in my opinion it still works quite well.

    • @groovebird812
      @groovebird812 4 роки тому

      @@adm7282 yes this is better, because card__item is not so meaningful. Every thing in the card is a card item and is does not explain that it belongs to a list.

  • @coolworx
    @coolworx Рік тому

    9:17
    "Spess Ah Fiss It eee"
    Say it fast 3 times. ;-)

  • @fromillia
    @fromillia 4 роки тому

    Be ware of BEM because this is a russian hackers thing from evelCorp YANDEX ! )

  • @jeannoelhonisch7037
    @jeannoelhonisch7037 2 роки тому

    i dont really understand, how the selector in css works, when you reference the name just with the the __name, just because its named differently in the html...

    • @jeannoelhonisch7037
      @jeannoelhonisch7037 2 роки тому

      oh wait i just scipped the last 20 sec so does that mean, that scss has a build in BEM selector in it, that puts the parent element in front when compiled back to css ?

  • @jennisonb37
    @jennisonb37 Рік тому

    Thank you for explaining BEM so clearly and succinctly. You got a new sub and I'm looking forward to watching some of the other videos you have.

  • @frozen_tortus
    @frozen_tortus 3 роки тому

    Annoying intro as always, but very nicely done video after the intro :). Good job!

  • @ead5590
    @ead5590 4 роки тому +13

    Yesssss! Finally somebody who I trust covering a topic that seemed to me like a mystery..
    I mean seriously.. When I was learning CSS, all that mattered in naming classes was something that was easy for me as a developer.. And then came along BEM, SMACSS, OOCSS and who knows what.. Like wtf.. 😵
    Thanks for talking about BEM Gary.. Now how about SMACSS, OOCSS.. 😁

    • @sugiono2801
      @sugiono2801 4 роки тому +1

      how do you know that name? SMACSS, OOCSS or maybe something thats never exists but actually exists?

    • @ead5590
      @ead5590 4 роки тому +1

      @@sugiono2801 Sup man! Well I'd taken a Udemy course by Jonas Schmedtmann named 'Advanced CSS and SASS' course. Within that he mentions of these methodologies for naming the various classes. But he uses the BEM method during the course.
      It would be worth noting these methods because recently when I was browsing through job postings on LinkedIn, there are postings where they ask you to have a fair amount of knowledge about a specific method such as BEM.

  • @TsunaSawada26
    @TsunaSawada26 4 роки тому +11

    I once used it but never again. The problem is that you class names become longer and longer and can be simplified with .card.button.active for example.

    • @edwingarcia5043
      @edwingarcia5043 4 роки тому +1

      specificity graph becomes crazy with that

  • @vladaxinte
    @vladaxinte 4 роки тому

    no, you don't. if you use CSS modules (which is what you should be using to write scalable CSS), the scope is always local and specificity issues disappear. look it up!

  • @ChrisAthanas
    @ChrisAthanas 3 роки тому

    Solid clear explanation

  • @craigdanielmaceacher
    @craigdanielmaceacher 4 роки тому

    @10:30 isn't the semantically tied to the card__content div just above it? It's nested inside that div so shouldn't it be card__content__ul? This is confusing

    • @CabbageYe
      @CabbageYe 4 роки тому

      It's very confusing, I don't like BEM personally

  • @riiad
    @riiad 4 роки тому

    Here's the only reason I liked this video :
    He directly, simply, clearly explains what is BEM. That it's a methodology and what's its purpose.
    It seems all the other guys just start talking and talking as if it's gonna be a philosophical talk. And you don't even have a clue of what BEM is.

  • @kacperkepinski4990
    @kacperkepinski4990 2 роки тому

    There are only one elem of everything...

  • @rathernotdisclose8064
    @rathernotdisclose8064 3 роки тому

    _ is an underscore. - is a hyphen.

  • @truvc
    @truvc 4 роки тому +1

    Styled components are the bomb. Svelte and react have completely made BEM obsolete from my life and I love it

  • @rosstee
    @rosstee 3 роки тому +7

    Thanks for a great intro to BEM. I used to do HTML/CSS years ago and need to pick it back up at work. These days my company uses BEM and SASS so this was perfect and very easy to follow.

  • @BenRangel
    @BenRangel 4 роки тому

    One minor annoyance I have with BEM is that you often get into refactoring discussions in your team as your DOM depth grows. You start out with "card" and "card__header". Later you might need to add a title and an image to the header. But BEM (wisely) forbids nested element-classes like "card__header__title". So then you get into the refactoring debate. Do we do ".card__header .title" or ".card header__title"?
    And then you might get into asking yourself why you're even using BEM. You could just do ".card .header .title"

  • @thefragbeast245
    @thefragbeast245 3 роки тому

    does bem work without sass?

  • @babayaga5848
    @babayaga5848 4 роки тому +1

    great stuff simon, can you please make a video that explain how to configure php for vsCode, so it can auto complete and other things like the atom built-in feature

  • @MeAsMeButMe
    @MeAsMeButMe 3 роки тому

    Specifity you say? ;D

  • @AcademyOmen
    @AcademyOmen 3 роки тому

    Great 💡, thanks

  • @diy-hobby
    @diy-hobby 3 роки тому

    I still dont get the point of BEM

  • @martinh4982
    @martinh4982 4 роки тому

    Don't do this. Do components.

  • @grapes639
    @grapes639 4 роки тому

    I use BEM, but one of the things I find the most annoying with it is how absurdly long some class names can get. Especially if you want to toggle a class. Like in your instance if you had a "card__button" and then you wanted to add the "active" class, the two classes alone would be long "card__button card__button--active" now imagine that and pairing it with more classes like for example col-12 col-lg-4 etc. I think the classes just end up looking hella messy after a while.

  • @sunflair-wa
    @sunflair-wa 2 роки тому

    Thank you so much. I feel like I have been given the secret handshake to the club :)

    • @GamingTSH
      @GamingTSH 2 роки тому +1

      🙏❤️ua-cam.com/video/lmIwYLFYZ9U/v-deo.html❤️🙏

  • @zayarlyn
    @zayarlyn 2 роки тому

    gonna follow that convention

  • @BenRangel
    @BenRangel 4 роки тому +1

    I dislike classname concatenation like "&__item". I would write the full classname; "card__item". Many new Sass-users fall in love with the idea of concatenating all classnames.
    My team used to do that but we decided it makes your code messier in the long run.
    A) You can't copy-paste a full classname from your html and search for it in your codebase. You always have to remember that only one part of the classname is searchable.
    B) You create a lot of nesting in your code. So when you find "&__item" you always have to look up to see what the full classname actually is.
    People will argue that "the advantage is that if you rename 'card' to something else, you just have to change it in one place in your sass file"
    But I'd argue this is NOT a major concern. I don't rename stuff that often, and when I do - search-and-replace only takes seconds.
    I do however search through and read my code all the time. So anything that increases readability is a more worthwhile investment.

    • @Arttyor
      @Arttyor 4 роки тому

      I agree, plus they still need to replace class name in HTML, so will end up using searc-and-replace anyway.
      Which css methology do you prefer?

    • @BenRangel
      @BenRangel 4 роки тому

      narkar:
      I like BEM as long as you’re not being needlessly strict about it and try to shoehorn it into every situation.
      We use utility-classes (like ”hidden”) in instances where the same behavior is reused often.
      I think it’s insane to use BEM classes for common features like that (for example using card-hidden and article-hidden if they both just set display:none)
      mostly use BEM mostly elements with many children. If an elem just has 1-2 children and no deep nesting I avoid BEM. ”article p” is fine.
      We use css preprocessor features where we think its most necessary.
      We avoid class name concatenation.
      But We use variables in cases where it make it more obvious how stuff relates to each other, especially for things like z-indexes. I hate seeing ”z-index: 95” , cause writing ”z:index: $popup-z-index + 1” is so much more understandable.
      We use variables to make sure we use standard measurements as often as possible like $padding-mobile and $padding-desktop but if something needs tweaking because of the font used we’re fine with doing an excepting and hard coding a pixel distance.
      We don’t use a grid-system for stuff like columns as we do a lot of different layouts for different pages and I think it’s much faster to write custom css for a rare case where we need 5 columns than to use bootstrap’s grid and hack some kind of 5-column-class.
      (But if we were building a more simple/cheap site that didn’t have time to do custom layouts we’d probably use more gris-systems)

    • @Arttyor
      @Arttyor 4 роки тому

      @@BenRangel That is neat tip for z-index. Thanks.
      I like using display: grid for it's autoplacement. I dont use bootstrap's grid at all.

  • @korkut31
    @korkut31 Рік тому

    wrong naming. very wrong.

  • @SquaredbyX
    @SquaredbyX 4 роки тому

    Modify your Blocks and their accompanying Elements... Today!!!

  • @chrisandrew_tv
    @chrisandrew_tv 4 роки тому

    BEMs weakness, if there’s one to be extracted from these comments, is its name. Blocks, elements; most of these people know what those are and that can make it confusing when there are more than 2 nest levels. What I take away from this is that it’s definitely useful if used thoughtfully, when considering the first slides: What blocks on are project are similar in HTML structure but unique in content nature or styling? Card, content, list, these terms are general but if I imagine a blog post preview, album preview, news article preview or rental listing, I can see how BEM would be beneficial. Thank you.

  • @SteveUrlz
    @SteveUrlz 2 роки тому

    Isn't it SpeciFIcity

  • @Atlanticwow
    @Atlanticwow 4 роки тому

    i think css is better than this

  • @davidnagy1046
    @davidnagy1046 4 роки тому +1

    thank you for the video! will you cover CSS-in-JS sometime soon?