CSS Borders

Used to define the style, width, and color of an element's border.


Border Properties

border

Sets the width, style, and color in one line.

p { border: 2px solid red; }

border-width

Sets the width of the border.

div { border-width: 5px; }

border-style

Defines the style of the border.

div { border-style: solid; }

div { border-style: dashed; }

div { border-style: dotted; }

div { border-style: double; }

div { border-style: groove; }

div { border-style: ridge; }

div { border-style: inset; }

div { border-style: outset; }

div { border-style: none; }

border-color

Sets the color of the border.

div { border-color: blue; }

Individual Borders

Set borders on specific sides using border-top, border-right, border-bottom, and border-left.

div { border-top: 3px solid red; }

div { border-right: 3px solid green; }

div { border-bottom: 3px solid blue; }

div { border-left: 3px solid yellow; }

Rounded Borders

Use border-radius to make corners rounded.

div { border: 2px solid black; border-radius: 10px; }

div { border-radius: 50%; }

Shorthand Border Radius

div { border-radius: 10px 20px 30px 40px; }

No Border

Remove the border completely.

div { border: none; }

HTML Logo