getbem.github.io
getbem.github.io copied to clipboard
can i use an element within a block?
I know that I can use a modifier within a block but,
can I do this ?
<span class="icon icon__item"> lorem ipsum </span>
According to convention icon__item would be a child element. What's wrong with just icon--item?
Did you mean icon is the parent? Then that means you are simply adding a modifier to the parent: icon Your modifier is --item. So please go for icon icon--item, because icon__item means 'item is the child of icon'. What you want is icon icon--item to say 'item is modifying the icon' 😃
Answer: <span class="icon icon--item"> lorem ipsum </span>
@area73 Are you using 'bootstrap' library? I agree with the guys who has commented, the BEM ideology says 'icon_item' must be treated as an element, and you can't have both of them in the same tag.
Actually it's possible to mix a block with its element on the same tag if there's a valid reason for such mix.