Contents
Defining the CSS border style
By using the CSS border-style
property, you can set custom styles for all four borders of an element:
div.one {border-style: solid dotted dashed dotted;}
/* top border - solid, right border - dotted, bottom border-dashed, left border - dotted */
div.two {border-style: dashed dotted double;}
/* top border - dashed, right border - dotted, bottom border - double */
div.three {border-style: dotted dashed;}
/* top and bottom border - dotted, right and left borders - dashed */
div.four {border-style: dashed;}
/* all borders - dashed */
Syntax for border styles
To create CSS border styles, follow the syntax example below:
border-style: value;
You can define from one to four values at once.
Syntax | Example | Explanation |
---|---|---|
One value | border-style: none; | The style is the same for all four sides. |
Two values | border-style: none dotted; | The first value defines the style for the top and bottom borders. The second value defines the style for the left and right borders. |
Three values | border-style: none dotted dashed; | The first value defines the style for the top border. The second value defines the style for the left and right borders. The third value defines the style for the bottom border. |
Four values | border-style: none dotted dashed double; | The first value defines the style for the top border. The second value defines the style for the right border. The third value defines the style for the bottom border. The fourth value defines the style for the left border. |
See all the possible values for CSS border styles defined in the following section.
Property values
Value | Description |
---|---|
none | The default value. No border is displayed |
hidden | No border is displayed |
dotted | A border of round dots is displayed |
dashed | A border of short dashes is displayed |
solid | A single solid border is displayed |
double | A double border is displayed |
groove | An inward-curving border is displayed |
ridge | An outward-curving border is displayed |
inset | An embedded border is displayed |
outset | An embossed border is displayed |