To design the shape of an HTML button we can use SVG elements (Scalable Vector Graphics). It basically defines the vector-based graphics in XML format. Every element and every attribute in SVG files can be animated. We can use SVG to create 2-D graphics of any custom shape.
Example 1: This example creating a circle shape button using SVG.
<!DOCTYPE html> <html> <head> <title> Create custom shape button </title> </head> <body> <h1 style="color:green;">GeeksforGeeks</h1> <h3>Circle Shape Button</h3> <svg width="500" height="500"> <a href="#"> <Circle cx="60" cy="60" r="50" stroke="black" fill="green" stroke-width="3"/> </a> </svg> </body> </html> |
Output:

There are many more shapes available in SVG elements such as boxes, text, rectangles, etc.
Example 2: This example creating a rectangle shape button using SVG.
<!DOCTYPE html> <html> <head> <title> Rectangle Shape Button </title> </head> <body> <h1 style="color:green;">GeeksforGeeks</h1> <h3>Rectangle Shape Button</h3> <svg width="300" height="200"> <a href="#"> <rect width="250" height="150" style="fill:rgb(0, 255, 0); stroke-width:5;stroke:rgb(0, 0, 0)" /> </a> </svg> </body> </html> |
Output:

Example 3: This example creating a star shape button using SVG.
<!DOCTYPE html> <html> <head> <title> Star Shape Button </title> </head> <body> <h1 style="color:green;">GeeksforGeeks</h1> <h3>Star Shape Button</h3> <a href="#"> <svg width="300" height="200"> <polygon points="100, 10 40, 198 190, 78 10, 78 160, 198" style="fill:green; stroke:black; stroke-width:5; fill-rule:evenodd;" /> </svg> </a> </body> </html> |
Output:

Example 4: This example creating a flag shape button using SVG.
<!DOCTYPE html> <html> <head> <title> Flag Shape Button </title> </head> <body> <h1 style="color:green;">GeeksforGeeks</h1> <h3>Flag Shape Button</h3> <svg width="240" height="240"> <a href="#"> <path d="M 0 0 L 120 0 L 120 120 L 60 80 L 0 120 Z" fill="green"/> <text x="60" y="50" fill="#FFFFFF" text-anchor="middle" alignment-baseline="middle"> GeeksforGeeks. </text> </a> </svg> </body> </html> |
Output:

Recommended Posts:
- How to Create Custom Radio Button using HTML and CSS ?
- How to create a radio button similar to toggle button using Bootstrap ?
- How to Create a Custom Image Magnifier using jQuery ?
- How to Create Custom Errors using New Function in Golang?
- How to create custom banner background using CSS ?
- How to create custom arrows for your website using HTML and CSS?
- How to trigger HTML button after hitting enter button in textbox using JavaScript ?
- How to change the shape of a textarea using JavaScript?
- How to create a custom callback in JavaScript?
- Service Worker | How to create custom offline page ?
- How to place SVG icons on a round circle side by side to another div using Bootstrap?
- button tag vs input type="button" attribute
- How to Create a Transparent button using HTML and CSS ?
- How to create Neon Light Button using HTML and CSS ?
- How to Create an Effect to Change Button Color using HTML and CSS ?
- How to create button to open SMS compose to a phone number using HTML ?
- How to create a shinny button using HTML and CSS ?
- How to create a button with stitched border using HTML and CSS?
- How to create Shaky button using HTML and CSS ?
- How to find record using any key-value pair information of record in your local/custom database using Node.js ?
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.


