Description & Usage

The border property draws a decorative or structural line around an element, situated between padding and margin layers.

It is a shorthand that sets border-width, border-style, and border-color simultaneously. Without specifying a border-style (such as solid, dashed, or dotted), no border will be rendered.

Borders add to element dimensions unless box-sizing is set to border-box.

Property Specifications

Property FeatureSpecification
CategoryBox Model
Initial Valuemedium none currentcolor
InheritedNo (not inherited)
Applies ToAll elements
Box Model Explorer
box-sizing:
margin: 20px
border: 4px
padding: 20px
Content (180px × 90px)
Rendered Element Size:180px × 90px
Fixed total width of 180px (Content auto-shrinks inside border)

Syntax

border: <border-width> <border-style> <border-color>;

Property Values

ValueDescription
1px solid #cbd5e1Thin solid gray border.
2px dashed #3b82f6Dashed blue border.

Code Examples

Card Border Highlight
.card { border: 1px solid #e2e8f0; border-radius: 8px; }
Creates a clean modern card container outline.