In this tutorial, we’ll go over some CSS techniques for rendering circular <img> elements. The main CSS property responsible for the effect is border-radius.
Though it’s quite simple to apply the effect to square images, rectangular images will require a little bit more extra work.
Learn how to create rounded and circular images with CSS.
How To Create Rounded Images
Step 1) Add HTML:
<img src="img_avatar.png" alt="Avatar">
Step 2) Add CSS:
Use the border-radius property to add rounded corners to an image. 50% will make the image circular:
img {
border-radius: 50%;
}
Full code :
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
img {
border-radius: 50%;
}
</style>
</head>
<body>
<h2>Rounded Images</h2>
<img src="img_avatar.png" alt="Avatar" style="width:200px">
</body>
</html>
I hope you like this Post, Please feel free to comment below, your suggestion and problems if you face – we are here to solve your problems.
Please follow and like us: