The CSS border property is great for adding stroke outlines to your elements, but it offers little flexibility when working with dashed borders. For example, you can't customise dash lengths, gaps between dashes, or even the caps on each dash. To overcome this, we'll be writing our own dashed border renderer using the new CSS Houdini Paint API . The full code is available at the end of the post and on GitHub here . Final result Note that as of 2021, the Paint API is not supported by Firefox or Safari, so if this feature is mission-critical to your project in these browsers, you might want to look for alternatives. Support tables for the API can be found here . Writing a Custom Paint Class To start with, we need to create a class that handles all the custom painting we'll be doing. It will be responsible for exposing available properties and drawing the actual borders themselves. As you can see, the class has a method that returns all properties we'd like t...