CSS border
- type
- property (shorthand)
- applies to
- any element
- inherits
- no
- common values
- 1px solid #ccc, none, 2px dashed red
Where it goes
On any box that needs a visible edge: a card, a text field, a divider.
Example
.card {
border: 1px solid #ccc;
border-radius: 8px;
}Common mistakes
- Setting border-color without a style. The style defaults to none, so without a word like solid nothing shows, whatever the color.
- Forgetting that the border adds to the box's size under the default box-sizing. Same gotcha as padding.