Introduction
Before reading further, read the following articles.
- Overview of Scalable Vector Graphics (SVG)
- Scalable Vector Graphics - Rectangle
- Scalable Vector Graphics - Circle
- Scalable Vector Graphics - Ellipse
- Scalable Vector Graphics - Line
- Scalable Vector Graphics - Polyline
- Scalable Vector Graphics - Polygon
Now let's proceed further to learn SVG Path.
SVG Path
The tag <path> describes a path. A path may consist of lines, arcs, curves and so on with or without fill. It can be stroked or used as input for other tags.
A path can also be used to define the same figures or structures as a line, polyline, polygon, circle, rect and so on tags. It contains a significant attribute “d” that is assigned a string of text that describes the path to be created.
Syntax
<svg>
<path d="M150 0 L75 200 L225 200 Z" /> </svg>
The syntax of path is a little more complex than the previous tags, but also more general. That is why the path tag is probably the most advanced and versatile SVG shape among them all and is very complex to handle.
The commands used in the path tag are as in the following.
<path d="M150 0 L75 200 L225 200 Z" /> </svg>
| Commands | Stands for | Description |
| M | moveto | Move from one point to another point |
| L | lineto | Create a line |
| H | horizontal lineto | Create a horizontal line |
| V | vertical lineto | Create a vertical lineto |
| C | curveto | Create a curve |
| S | smooth curveto | Create a smooth curve |
| Q | quadratic Bezier curveto | Create a quadratic Bezier curve |
| T | smooth quadratic Bezier curveto | Create a smooth quadratic Bezier curve |
| A | elliptical Arc | Create an elliptical arc |
| Z | closepath | Close the path |
Note: The preceding commands are in upper case that represents absolute position or path. All the commands can also be expressed with lower case letters that represents relative position or path.
Let's see a few examples of path.
Example 1
In this example we will draw a line that can be done using the L or l command. And we are using the L command for absolute positioning.
- <html>
- <body>
- <svg height="300" width="500">
- <path d="M20,20 L120, 120" style="stroke:lime; stroke-width:3;" />
- <path d="M180,20 L70, 110" style="stroke:red; stroke-width:3; stroke-dasharray:10 3;" />
- </svg>
- </body>
- </html>

- <html>
- <body>
- <svg height="300" width="500">
- <path d="M20,20 L120, 20" style="stroke:red; stroke-width:3;" />
- <path d="M20,20 l20, 120" style="stroke:blue; stroke-width:3;" />
- </svg>
- </body>
- </html>

- <html>
- <body>
- <svg height="300" width="700">
- <path d="M20,20 H200,20" style="stroke:green; stroke-width:3;" />
- <path d="M20,20 V20,120" style="stroke:orange; stroke-width:3;" />
- <path d="M200,20 V120,120" style="stroke:green; stroke-width:3; stroke-dasharray:10 3;" />
- <path d="M200,120 H20,120" style="stroke:orange; stroke-width:3; stroke-dasharray:10 3;" />
- <path d="M220,20 L280,20 H" style="stroke:tomato; stroke-width:3;" />
- <path d="M220,20 L220,120 V" style="stroke:blue; stroke-width:3;" />
- <path d="M220,120 L280,120 H" style="stroke:tomato; stroke-width:3;" />
- <path d="M300,20 L360,20 H" style="stroke:cyan; stroke-width:3;" />
- <path d="M300,20 L300,70 V" style="stroke:lime; stroke-width:3;" />
- <path d="M300,70 L360,70 H" style="stroke:blue; stroke-width:3; stroke-dasharray:10 3;" />
- <path d="M360,70 L360,120 V" style="stroke:lime; stroke-width:3;" />
- <path d="M360,120 L300,120 H" style="stroke:cyan; stroke-width:3;" />
- </svg>
- </body>
- </html>

- <html>
- <body>
- <svg height="300" width="700">
- <path d="M100,20 L20,120 L180,120 Z" style="stroke:green; stroke-width:3; fill:lightblue;" />
- <path d="M250,20 L350,20 L350,120 L250,120 Z" style="stroke:red; stroke-width:3; fill:yellow; stroke-dasharray:10 3;" />
- </svg>
- </body>
- </html>

Want to read more.
Thank you, keep learning and sharing.

Gopi ChandPosted Aug 19, 2015, 6:57 AM
Pleasure is all mine :)
Afzaal Ahmad ZeeshanPosted Jul 29, 2015, 3:37 PM
Gopi, a question. In the title, did you intend to write Path 1 or was it Part 1? I think, you meant to write Part 1.
Gopi ChandPosted Jul 28, 2015, 11:52 AM
Thanks to all of you... :)
Shridhar SharmaPosted Jul 28, 2015, 10:47 AM
good one :)
Santhakumar MunuswamyPosted Jul 27, 2015, 2:35 PM
Thanks for nice article:)
Neeraj KumarPosted Jul 27, 2015, 12:55 PM
Nice
SharadPosted Jul 27, 2015, 6:21 AM
good one..
Gowtham RajamanickamPosted Jul 27, 2015, 5:19 AM
good
Sibeesh VenuPosted Jul 27, 2015, 12:40 AM
Nice Share. Thanks
RakeshPosted Jul 26, 2015, 11:42 PM
Good one sir