CSS Borders

Adding Borders

CSS border properties allow you to specify the style, width, and color of an element's border.

/* Border Style */
p {
  border-style: solid;
  border-width: 2px;
  border-color: black;
}

/* Border Shorthand */
div {
  border: 3px dashed red;
}

/* Individual Sides */
h1 {
  border-top: 2px solid blue;
  border-bottom: 2px solid blue;
}

/* Rounded Corners */
.box {
  border: 2px solid #333;
  border-radius: 10px;
}
  • border-style - solid, dashed, dotted, double, etc.
  • border-width - Thickness of border
  • border-color - Color of border
  • border-radius - Rounded corners
  • border - Shorthand property

Try Borders

<div class="solid">Solid Border</div>
<div class="dashed">Dashed Border</div>
<div class="rounded">Rounded Border</div>

Note: border-radius creates rounded corners. Use 50% for perfect circles.