Ask DN: Question for BEM enthisiests

3 years ago from , Lead UX Designer @ Upserve

When you are defining a class, are you including every parent element?

For example: You have a container .content with a child .content__metadata and .content__metadata has a child ".timestamp".

Given that the selector will be namespaced to the block and there will only be one .timestamp in this block, would you give the .timestamp class a name of .content__metadata__timestamp or .content__timestamp?

4 comments

  • Matt Sisto, 3 years ago

    -1 DN, for not allowing editing of first posts & titles.

    1 point
  • Benoit DezielBenoit Deziel, 3 years ago

    I would rename .content__metadata to .metadata and use .metadata__timestamp

    0 points
    • Matt Sisto, 3 years ago (edited 3 years ago )

      This .metadata is only relevant to .content. There may be other instances of .metadata.

      0 points
      • Benoit DezielBenoit Deziel, 3 years ago (edited 3 years ago )

        Will the other instances of .metadata have a timestamp element?

        0 points