K
K
kid-programmer2015-10-11 15:45:55
css
kid-programmer, 2015-10-11 15:45:55

BEM, block or element?

Hello! I comprehend BEM and the question arose, when is a block and when is an element?
For example, there is a page on which there is a specific footer... this footer will be only on this page and nowhere else, and there is also a footer that is common to everyone.
Is it right to make a page-specific footer an element...

//специфический footer для страницы
.home-page__footer{}
.home-page__footer-content{}
.home-page__footer-item{}

//mod 
.home-page__footer-item_left{}
.home-page__footer-item_right{}

and general
.footer{}
.footer__content{}
.footer__item{}

in general, how to understand where it is better to make a block and where is an element? and in general, did I understand BEM correctly by the name of the classes

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Andrey, 2015-10-11
@kid-programmer

The block makes sense regardless of the context. The footer only makes sense as a page element. Plus, the footer almost always has some characteristics that determine its position: position, margin... etc. That immediately characterizes it as an element.
But this is if we consider it as part of one project. And if you look wider, then the same footer structure can be used in different projects. For a page, this is an element, but in general it can be a block.
So I think it's like this:
At the same time, the page__footer class should be given styles that determine its position on the page, and the footer class - everything else.
If the footer is different on one page, then it should be redefined through a modifier. If there are differences in position, then the element should be modified: page__footer_modificator , if there are differences in design, modify the block: footer_modificator

K
kid-programmer, 2015-10-11
@kid-programmer

he asked and answered himself;) here is the answer

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question