CSS borders are used to create visual separation between elements by adding a boundary around them. Borders can have different styles, colors, and thicknesses to enhance the design of a webpage.
Property | Description |
---|---|
border |
A shorthand for all border properties. |
border-width |
Sets the thickness of the border. |
border-style |
Defines the style of the border (solid, dashed, etc.). |
border-color |
Specifies the color of the border. |
border-radius |
Rounds the corners of the border. |
border-style
)The border-style
property defines the appearance of the border.
p {
border-style: solid;
}
✅ Common Border Styles:
solid
→ A continuous linedotted
→ Dotsdashed
→ Dashesdouble
→ Two solid linesgroove
→ 3D effect (like carved in)ridge
→ 3D effect (like raised)inset
→ Appears pressed inoutset
→ Appears raised
border-width
)Controls the thickness of the border.
div {
border-style: solid;
border-width: 5px;
}
✅ You can specify:
2px
, 5px
, 10px
)💡 You can also specify different widths for each side: