Skip to content

Why are elements a thing with syntax? #160

@mindplay-dk

Description

@mindplay-dk

I didn't find this covered in the FAQ, so:

I get the -- separator for modifiers is necessary - you need a reserved sequence to disambiguate from other word separators and prevent collisions.

What I don't get, is why do you need the __ separator to separate blocks and elements?

Let's say you have a panel block, and a panel__title element.

While still following BEM, I could instead choose to merely describe the same components as a panel block and a second panel-title block, right?

These would be functionally equivalent, and we're not supposed to rely on cascading rules in any case, right?

Which would seem to imply that the panel__title element would work just as well without the panel block as a parent.

So it seems the choice between the two is completely arbitrary. You don't strictly need to have any elements at all.

It also doesn't prevent collisions, except between my own panel__title and panel-title, which is totally ambiguous, and I'd never have those in the first place. My panel__title element or panel-title block can both collide with yours - we'll need namespace prefixes to prevent that case either way.

The only function I can see this having, is communicating intent - the use of the __ could suggest "you're supposed to use these together", but again, block and block-title suggest this just as well, and it's more idiomatically what CSS authors everywhere have been doing practically forever.

On top of which, following that convention only suggests a direct relationship between a parent and child - it does not indicate or suggest any internal parent/child relations between individual elements, so you'll need a style guide for the precise structure of complex components anyway.

Am I missing something?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions