This trick works for both horizontal and vertical borders:
/*Horizontal*/
background-image: linear-gradient(to right, black 33%, rgba(255,255,255,0) 0%);
background-position: bottom;
background-size: 3px 1px;
background-repeat: repeat-x;
/*Vertical*/
background-image: linear-gradient(black 33%, rgba(255,255,255,0) 0%);
background-position: right;
background-size: 1px 3px;
background-repeat: repeat-y;
You can adjust the size with background-size and the proportion with the linear-gradient percentages. In this example I have a dotted line of 1px dots and 2px spacing. This way you can have multiple dotted borders too using multiple backgrounds.
Try it in this JSFiddle or take a look at the code snippet example:
div {_x000D_
padding: 10px 50px;_x000D_
}_x000D_
.dotted {_x000D_
border-top: 1px #333 dotted;_x000D_
}_x000D_
.dotted-gradient {_x000D_
background-image: linear-gradient(to right, #333 40%, rgba(255, 255, 255, 0) 20%);_x000D_
background-position: top;_x000D_
background-size: 3px 1px;_x000D_
background-repeat: repeat-x;_x000D_
}_x000D_
.dotted-spaced {_x000D_
background-image: linear-gradient(to right, #333 10%, rgba(255, 255, 255, 0) 0%);_x000D_
background-position: top;_x000D_
background-size: 10px 1px;_x000D_
background-repeat: repeat-x;_x000D_
}_x000D_
.left {_x000D_
float: left;_x000D_
padding: 40px 10px;_x000D_
background-color: #F0F0DA;_x000D_
}_x000D_
.left.dotted {_x000D_
border-left: 1px #333 dotted;_x000D_
border-top: none;_x000D_
}_x000D_
.left.dotted-gradient {_x000D_
background-image: linear-gradient(to bottom, #333 40%, rgba(255, 255, 255, 0) 20%);_x000D_
background-position: left;_x000D_
background-size: 1px 3px;_x000D_
background-repeat: repeat-y;_x000D_
}_x000D_
.left.dotted-spaced {_x000D_
background-image: linear-gradient(to bottom, #333 10%, rgba(255, 255, 255, 0) 0%);_x000D_
background-position: left;_x000D_
background-size: 1px 10px;_x000D_
background-repeat: repeat-y;_x000D_
}
_x000D_
<div>no_x000D_
<br>border</div>_x000D_
<div class='dotted'>dotted_x000D_
<br>border</div>_x000D_
<div class='dotted-gradient'>dotted_x000D_
<br>with gradient</div>_x000D_
<div class='dotted-spaced'>dotted_x000D_
<br>spaced</div>_x000D_
_x000D_
<div class='left'>no_x000D_
<br>border</div>_x000D_
<div class='dotted left'>dotted_x000D_
<br>border</div>_x000D_
<div class='dotted-gradient left'>dotted_x000D_
<br>with gradient</div>_x000D_
<div class='dotted-spaced left'>dotted_x000D_
<br>spaced</div>
_x000D_