Git Product home page Git Product logo

Comments (4)

anthwinter avatar anthwinter commented on August 21, 2024

You can have multiple elements within a block, for example:

.menu {}
    .menu__list {}
    .menu__list-item {}
    .menu__link {}

Then the html would be:

  • link

This is the approach I have taken on a project recently.

from css-guidelines.

fxck avatar fxck commented on August 21, 2024

Yeah, that's what I said in "The other option would be to give the li some BEM class as well, like .menu__listitem along the class for a which would be .menu_item" but then you are kind of much coupling it with html, aren't you?

On the other hand, for this particular case I could use the utility class, and the other cases I was talking about could probably be dealt with using another elements..

from css-guidelines.

csswizardry avatar csswizardry commented on August 21, 2024

Hey!

If you were to use BEM, you would have:

.menu {}
    .menu__item {}
        .menu__link {}

but then you are kind of much coupling it with html, aren't you?

The opposite :)

A selector like .menu > li {} is tightly coupled to the HTML in that you have to use lis. Using a class means that, for whatever reason, that styling could be applied to anything :)

BEM can seem redundant at times, but it’s a powerful naming convention that, for the most part, works perfectly :)

from css-guidelines.

fxck avatar fxck commented on August 21, 2024

Thanks!

from css-guidelines.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.