N
N
Norum2021-09-18 00:09:50
BEM
Norum, 2021-09-18 00:09:50

Are these BEM rules correct?

From the articles I read, I wrote a few rules for myself to make it easier to navigate, but I'm not sure if they are correct and I have a request to confirm their correctness or correct them. It will also be good if you supplement them

1) The block is universal and independent (ideally). It can be placed anywhere on the site without compromising its own appearance. Therefore, the blocks are not given styles that affect positioning.

2) An element is an integral part of a block that does not exist outside of it. Therefore, the element can be positioned within its block (different indents).

3) Modifiers in BEM set the appearance, state and behavior of blocks.

4) Mixes allow you to combine the behavior and styles of several entities without code duplication

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vitaly Pershin, 2021-09-18
@Get-Web

1) The block is universal and independent (ideally). It can be placed anywhere on the site without compromising its own appearance. Therefore, the blocks are not given styles that affect positioning.

Yes, but not because it is so universal, but because its styles will not be overridden by nested styles and increased specificity. If we insert a horizontal menu into a narrow sidebar, it will not become vertical, but it will not change its natural behavior due to context.
2) An element is an integral part of a block that does not exist outside of it. Therefore, the element can be positioned within its block (different indents).

Yes.
3) Modifiers in BEM set the appearance, state and behavior of blocks.

Yes, both blocks and elements, so as not to resort to nesting and not to increase specificity.
4) Mixes allow you to combine the behavior and styles of several entities without code duplication

Mixes are more suitable for redefining the style of a block or element in the context of another block, but no one forbids combining

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question