How can I display an image inside SVG circle in html5?

Here is an example elaborating on Havenard’s comment above:

<svg width="500" height="250">
    <defs>
        <clipPath id="circleView">
            <circle cx="250" cy="125" r="125" fill="#FFFFFF" />
        </clipPath>
    </defs>
    <image 
      width="500" 
      height="250" 
      xlink:href="https://www.amrita.edu/sites/default/files/news-images/new/news-events/images/l-nov/grass.jpg" 
      clip-path="url(#circleView)"
    />
 </svg>

You don’t actually draw a <circle> element with an image inside – instead, define a circular clip path, and set it as the ‘clip-path’ attribute on the <image> tag.

Leave a Comment