M
M
Michael R.2018-10-17 12:54:59
css
Michael R., 2018-10-17 12:54:59

How to correctly name CSS classes according to BEM using an example?

Greetings!
For example, I threw in a news output template.
1. How would you name the classes in the provided example within the BEM framework?
2. Is it wise to use ul lists in my example? Or is it better to use div here?
I wrote comments in the template for clarity.
Thank you!

<!-- главный блок с новостями -->
<div class="news">
  
  <!-- контейнер с новостями -->
  <ul class="list">
    
    <!-- колонка с новостью -->
    <li class="column">
      
      <!-- контейнер с новостью -->
      <ul class="list">
        
        <!-- заголовок новости -->
        <li class="title">Заголовок новости</li>
        
        <!-- дата новости -->
        <li class="date">
          <span class="time">10:00</span>
          <span class="date">01.01.2000</span>
        </li>
        
        <!-- описание новости -->
        <li class="description">Описание новости</li>
        
      </ul>
      
    </li>
    
  </ul>
  
</div>

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry, 2018-10-17
@Mike_Ro

<!-- главный блок с новостями -->
<div class="news">
  
  <!-- контейнер с новостями -->
  <ul class="news__list">
    
    <!-- колонка с новостью -->
    <li class="news__column">
      
      <!-- контейнер с новостью -->
      <div class="news__item">
        
        <!-- заголовок новости -->
        <h2 class="news__title">Заголовок новости</h2>
        
        <!-- дата новости -->
        <div class="news__date">
          <span class="news__date-time">10:00</span>
          <span class="news__date-when">01.01.2000</span>
        </div>
        
        <!-- описание новости -->
        <div class="news__desc">Описание новости</div>
        
      </div>
      
    </li>
    
  </ul>
  
</div>

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question