Search code examples
htmlcsssvgpathcss-shapes

How to merge curve and line shape together in svg path


I have created an SVG shape in HTML and its a straight line with a curve in it. the problem is I don't know how to merge them I added Z Close Path command but it doesn't merge the shape as I want I researched a lot but I couldn't find a solution. below is the screenshot of a Shape that I want to achieve.

and the below shape is what I did which is fine but I want to merge all the path.

enter image description here

SVG CODE

<svg viewBox="0 0 100 100">
        <path stroke="blue" stroke-width=".7" fill="transparent" d="M14 10 H12 V35 H25 V10 H23 M14 10 C 14 17, 23 17, 23 10 " />
</svg>

Solution

  • You need to keep only the first M command. I reversed your last curve so that you don't need move back to the first point. Also I've added a z command at the end of the d attribute to close the path.

    <svg viewBox="0 0 50 50">
            <path stroke="blue" stroke-width=".7" fill="transparent" 
                  d="M14 10 
                     H12 
                     V35 
                     H25 
                     V10 
                     H23 
                     C 23 17, 14 17, 14 10 z" />
    
    </svg>