subash subash - 3 months ago 25
Javascript Question

Simple SVG Path not working

i have tried some basic examples like text, rect, circle, everything went fine. i just moved to

Path
element. I struggle to view the path in the browser. This is the code snippet i used

<svg width="500" height="200">
<path d="M 20 35 L 120 100 Z"> </path>
</svg>


but seems its not working. i have tested chrome and firefox. can someone figure it out in correct way. Thanks in advance.
also i just created a fiddle here

Answer

It is simple!
Try to add stroke and stroke-width attributes for showing the path:

<svg width="500" height="200">
    <path stroke="#f00" stroke-width="3" d="M 20 35 L 120 100 Z"> </path>
</svg>

Or add the third point like this:

<svg width="500" height="200">
    <text y="20">SVG Test</text>
    <path d="M 20 35 L 120 100 L 0 100 Z"> </path>
</svg>