E
E
EarthFM2016-02-04 16:20:42
BEM
EarthFM, 2016-02-04 16:20:42

Is it possible to specify color, font for a block in styles?

Hello. I correctly understood that it is impossible to write styles (color, background, font, margin, padding) in the block. This must be done in modifiers. And what should be written in the block?
And I found this rule

The width of a block always fills all available space, the height of a block that has content is never fixed.

I understood about height, but about width it's not entirely clear, should I specify width: 100% ?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
Konstantin Velichko, 2016-02-10
@EarthFM

Everything is simple. The main concept is the separation of design from positioning.
But you need to try to write styles so that there are no problems in the future. Let's say it's unnecessary to write color: red on the block itself, because then you will have to interrupt it at the element.
The simplest example

<div class="page page_sidebar_right">
  <div class="page__sidebar"></div>
  <div class="page__content"></div>
</div>

Here, the sidebar and content elements set the positioning, and the modifier somehow changes it.
We do not care what blocks will lie inside these elements, but these blocks must fill them, i.e. they don't have to have a width specified. Padding if needed for positioning will also be on these elements.
PS. width: 100% is not the same as display: block

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question