Menu
×
   ❮     
HTML CSS JAVASCRIPT SQL PYTHON JAVA PHP HOW TO W3.CSS C C++ C# BOOTSTRAP REACT MYSQL JQUERY EXCEL XML DJANGO NUMPY PANDAS NODEJS R TYPESCRIPT ANGULAR GIT POSTGRESQL MONGODB ASP AWS AI GO KOTLIN SASS VUE GEN AI SCIPY CYBERSECURITY DATA SCIENCE
     ❯   

SVG Stroke Properties


SVG Stroke Properties

SVG offers a wide range of stroke properties. In this chapter we will look at the following:

  • stroke
  • stroke-width
  • stroke-linecap
  • stroke-dasharray

All the stroke properties can be applied to any kind of lines, text and outlines of elements like a circle.


SVG stroke Property

The stroke property defines the color of a line, text or outline of an element:

Sorry, your browser does not support inline SVG.

Here is the SVG code:

Example

<svg height="80" width="300">
  <g fill="none">
    <path stroke="red" d="M5 20 l215 0" />
    <path stroke="black" d="M5 40 l215 0" />
    <path stroke="blue" d="M5 60 l215 0" />
  </g>
</svg>
Try it Yourself »

SVG stroke-width Property

The stroke-width property defines the thickness of a line, text or outline of an element:

Sorry, your browser does not support inline SVG.

Here is the SVG code:

Example

<svg height="80" width="300">
  <g fill="none" stroke="black">
    <path stroke-width="2" d="M5 20 l215 0" />
    <path stroke-width="4" d="M5 40 l215 0" />
    <path stroke-width="6" d="M5 60 l215 0" />
  </g>
</svg>
Try it Yourself »


SVG stroke-linecap Property

The stroke-linecap property defines different types of endings to an open path:

Sorry, your browser does not support inline SVG.

Here is the SVG code:

Example

<svg height="80" width="300">
  <g fill="none" stroke="black" stroke-width="6">
    <path stroke-linecap="butt" d="M5 20 l215 0" />
    <path stroke-linecap="round" d="M5 40 l215 0" />
    <path stroke-linecap="square" d="M5 60 l215 0" />
  </g>
</svg>
Try it Yourself »

SVG stroke-dasharray Property

The stroke-dasharray property is used to create dashed lines:

Sorry, your browser does not support inline SVG.

Here is the SVG code:

Example

<svg height="80" width="300">
  <g fill="none" stroke="black" stroke-width="4">
    <path stroke-dasharray="5,5" d="M5 20 l215 0" />
    <path stroke-dasharray="10,10" d="M5 40 l215 0" />
    <path stroke-dasharray="20,10,5,5,5,10" d="M5 60 l215 0" />
  </g>
</svg>
Try it Yourself »

W3Schools is optimized for learning and training. Examples might be simplified to improve reading and learning. Tutorials, references, and examples are constantly reviewed to avoid errors, but we cannot warrant full correctness of all content. While using W3Schools, you agree to have read and accepted our terms of use, cookie and privacy policy.

Copyright 1999-2023 by Refsnes Data. All Rights Reserved. W3Schools is Powered by W3.CSS.