Web Analytics

CSS Borders

Beginner ~8 min read

Border Styles

The border-style property defines the type of border. You must set this before the border will appear.

HTML
CSS
JS

Border Width & Color

Control border thickness with border-width and color with border-color.

HTML
CSS
JS

Border Shorthand

The border shorthand combines width, style, and color in one line: border: width style color;

HTML
CSS
JS

Individual Sides

You can style each side independently using border-top, border-right, border-bottom, and border-left.

HTML
CSS
JS

Border Radius (Rounded Corners)

The border-radius property creates rounded corners. Use pixels or percentages.

HTML
CSS
JS
Pro Tip: Use border-radius: 50% on a square element to create a perfect circle!

Summary

  • border-style - solid, dashed, dotted, double, etc.
  • border-width - Thickness in px, em, etc.
  • border-color - Any CSS color value
  • border - Shorthand: width style color
  • border-radius - Rounded corners
  • Individual sides: border-top, border-right, etc.

Quick Quiz

Which property creates rounded corners?

A
border-style
B
border-radius
C
border-round
D
corner-radius