Border (CSS)

The border is the line drawn around an element, sitting between its padding and its margin in the box model. You control its width, style, and color.

Web

The border shorthand combines three values: width, style (such as solid, dashed, or dotted), and color. You can also style individual sides.

Pair border with border-radius to round the corners, a common way to create pill-shaped buttons and rounded cards.

Examples

CSS

.card {
  border: 1px solid #ccc;
  border-radius: 8px;
}

Output:

Renders a card with a thin light-gray border and softly rounded corners.

Learn it in a lesson

See also

Back to the Dictionary