Skip to main content
D
CSS
CSS Borders

CSS Borders

CSS borders draw lines around HTML elements.

Read Time
5 min read
Difficulty
Beginner
Last Updated
Jun 15, 2026
Version
v1.0.0

Introduction

CSS border properties control the style, width, and color of an element's border. Developers create solid boxes, dashed outlines, or thick dividing lines. A border sits between the padding and the margin.

Syntax

Syntax
1/* border syntax */
2div {
3  border: 2px solid red;
4}

Example

Example
1/* this creates borders */
2p.solid {
3  border-style: solid;
4  border-width: 5px;
5  border-color: blue;
6}

Key Points

  • The `border-style` property is required to show a border.
  • The `border-width` property changes the thickness.
  • The `border-color` property sets the line color.
  • The `border` shorthand property combines all three.

Up Next

Continue your journey with the next topic.

Go to CSS Margins