Search code examples
csssvgd3.jsborder

How to add border/outline/stroke to SVG elements in CSS?


I'am injecting SVG elements into a webpage thanks to D3js. I have difficulties to style these elements since syntaxes like

path { border: 3px solid green; }

doesn't work.

How to add border/outline/stroke to SVG elements in webpages with CSS ?


Solution

  • In CSS, something like:

    path {
      fill: none;
      stroke: #646464;
      stroke-width: 1px;
      stroke-dasharray: 2,2;
      stroke-linejoin: round;
    }