Why does Bootstrap use “btn” classes? #32068
-
When creating a We already know that we are making a
I suppose the same question can be asked for badges, alerts and icons. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
This is a super old post from me, but it hits at the heart of it: https://markdotto.com/2012/02/16/scope-css-classes-with-prefixes/. A talk I last gave years ago also explains the approach even more: https://speakerdeck.com/mdo/at-mdo-ular-css. And then there's https://getbootstrap.com/docs/4.5/extend/approach/#classes. Bottom line, |
Beta Was this translation helpful? Give feedback.
This is a super old post from me, but it hits at the heart of it: https://markdotto.com/2012/02/16/scope-css-classes-with-prefixes/. A talk I last gave years ago also explains the approach even more: https://speakerdeck.com/mdo/at-mdo-ular-css. And then there's https://getbootstrap.com/docs/4.5/extend/approach/#classes.
Bottom line,
.primary
is meaningless withoutbtn-
in front of it. Attaching it tobutton.primary
makes the class more specific, or more difficult to override later.