CSS .class selector
- type
- selector
- applies to
- every element carrying that class
- inherits
- n/a
- common values
- .card, .btn, .active
Where it goes
Anywhere the same look is needed on several tags that are not related in any other way.
Example
.card {
border: 1px solid #ccc;
padding: 16px;
}Common mistakes
- Naming classes after how something looks (.red-text) instead of what it is (.error). The look will change. The name should not have to.
- Doubling up classes in the selector (.card.card) to force a rule to win, instead of checking why the first rule lost.