A
A
Alexey Verkhovtsev2017-01-08 09:20:11
BEM
Alexey Verkhovtsev, 2017-01-08 09:20:11

What is a BEM entity anyway?

Hello everyone, I have already made a couple of pages using the BEM methodology, but a question arises. For example, I have a BEM entity article that contains a category element, an article title element, and a short text element. But the other page contains a similar entity, also a selection from the category, but this entity already contains only the element title of the article and the picture of the article, that is, they are visually similar, but can this be attributed to the same article entity? Can one entity have some elements and another one? Tell me please

Answer the question

In order to leave comments, you need to log in

2 answer(s)
O
Oleg, 2017-01-08
@werty1001

Can one entity have some elements and another one?

Yes, there can be different elements in one block in different places on the site.
Headings, pictures, paragraphs, buttons, links - these are all independent blocks.

V
vintage, 2017-01-08
@vintage

It's easiest to assume that all elements are "completely independent blocks" (my-article, my-title, my-description, ...). In this case, if block A (for example, my-title) in the context of block B (for example, my-article) needs to be somehow additionally styled, then the class "element of block B" is added to it (for example, my-article-title).
The names must match the semantics. For example, you might have a my-image block that displays an image. But in the context of my-profile, you can have many different pictures, so you need to give them appropriate names: my-profile-photo, my-profile-avatar, and so on.

<div class="my-profile">
    <div class="my-image my-profile-photo" />
    <div class="my-image my-profile-avatar" />
</div>

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question