Home > Software engineering >  SVG Error: <path> attribute d: Unexpected end of attribute
SVG Error: <path> attribute d: Unexpected end of attribute

Time:11-11

I'm getting a browser console error from an SVG path. I'm not sure how to fix this, or which part of the path is incorrectly configured (I didn't make the path).

Error: <path> attribute d: Unexpected end of attribute. Expected number, "….907L9.5 0l2.792".
<path d="M9.5 14.25l-5.584 2.936 1.066-6.218L.465 6.564l6.243-.907L9.5 0l2.792" />

Is anyone able to tell help me out here? I know there have been a couple of similar questions - please don't mark as duplicate, each path is unique. Thanks.

CodePudding user response:

I guess the path has been cropped/clipped in svg markup.

The reason for this error:
There is an incomplete l – relative lineto command – missing a y coordinate. You should also close your path by a z command.

<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100">
   <path d="M9.5 14.25l-5.584 2.936 1.066-6.218L.465 6.564l6.243-0.907L9.5 0z" />
</svg>
<iframe name="sif1" sandbox="allow-forms allow-modals allow-scripts" frameborder="0"></iframe>

CodePudding user response:

Try pasting the complete svg markup into this tool : https://jakearchibald.github.io/svgomg/ Sometimes it will fix malformed paths.

I tried doing it and I see half of a star. Not sure if that's correct. I had to guess at its dimensions though since you didn't include the rest of the svg, so its not a very good test.

  • Related