The Modern Guide For Making CSS Shapes<\/h1>\nTemani Afif<\/address>\n 2024-05-10T13:00:00+00:00
\n 2024-06-12T20:05:40+00:00
\n <\/header>\n
You have for sure googled \u201chow to create [shape_name]<\/em> with<\/em> CSS\u201d<\/em> at least once in your front-end career if it\u2019s not something you already have bookmarked. And the number of articles and demos you will find out there is endless.<\/p>\nGood, right? Copy that code and drop it into the ol\u2019 stylesheet. Ship it!<\/em><\/p>\nThe problem is that you don\u2019t understand how the copied code works. Sure, it got the job done, but many of the most widely used CSS shape snippets are often dated and rely on things like magic numbers to get the shapes just right. So, the next time you go into the code needing to make a change to it, it either makes little sense or is inflexible to the point that you need an entirely new solution.<\/p>\n
So, here it is, your one-stop modern guide for how to create shapes in CSS<\/strong>! We are going to explore the most common CSS shapes while highlighting different CSS tricks and techniques that you can easily re-purpose for any kind of shape. The goal is not to learn how to create specific shapes but rather to understand the modern tricks that allow you to create any kind of shape you want.<\/p>\nTable of Contents<\/h3>\n
You can jump directly to the topic you\u2019re interested in to find relevant shapes or browse the complete list<\/a>. Enjoy!<\/p>\n\n- Hexagons<\/a><\/li>\n
- Octagons<\/a><\/li>\n
- Stars<\/a><\/li>\n
- Polygons & Starbursts<\/a><\/li>\n
- Parallelograms & Trapezoids<\/a><\/li>\n
- Circles & Holes<\/a><\/li>\n
- Border Edges<\/a><\/li>\n
- Rounded Arcs<\/a><\/li>\n
- Dashed Circles<\/a><\/li>\n
- Rounded Tabs<\/a><\/li>\n
- Triangles<\/a><\/li>\n
- Hearts<\/a><\/li>\n
- Ribbons<\/a><\/li>\n
- Tooltips & Speech Bubbles<\/a><\/li>\n
- Cutting Corners<\/a><\/li>\n
- Section Dividers<\/a><\/li>\n
- Floral Shapes<\/a><\/li>\n<\/ul>\n
Why Not SVG?<\/h2>\n
I get asked this question often, and my answer is always the same: Use SVG if you<\/em> can!<\/em> I have nothing against SVG. It\u2019s just another approach for creating shapes using another syntax with another set of considerations. If SVG was my expertise, then I would be writing about that instead!<\/p>\nCSS is my field of expertise, so that\u2019s the approach we\u2019re covering for drawing shapes with code. Choosing CSS or SVG is typically a matter of choice. There may very well be a good reason why SVG is a better fit for your specific needs.<\/p>\n
Many times, CSS will be your best bet for decorative things or when you\u2019re working with a specific element in the markup that contains real content to be styled. Ultimately, though, you will need to consider what your project\u2019s requirements are and decide whether a CSS shape is really what you are looking for.<\/p>\n
Your First Resource<\/h2>\n
\n 2024-06-12T20:05:40+00:00
\n <\/header>\n
Good, right? Copy that code and drop it into the ol\u2019 stylesheet. Ship it!<\/em><\/p>\n The problem is that you don\u2019t understand how the copied code works. Sure, it got the job done, but many of the most widely used CSS shape snippets are often dated and rely on things like magic numbers to get the shapes just right. So, the next time you go into the code needing to make a change to it, it either makes little sense or is inflexible to the point that you need an entirely new solution.<\/p>\n So, here it is, your one-stop modern guide for how to create shapes in CSS<\/strong>! We are going to explore the most common CSS shapes while highlighting different CSS tricks and techniques that you can easily re-purpose for any kind of shape. The goal is not to learn how to create specific shapes but rather to understand the modern tricks that allow you to create any kind of shape you want.<\/p>\n You can jump directly to the topic you\u2019re interested in to find relevant shapes or browse the complete list<\/a>. Enjoy!<\/p>\n I get asked this question often, and my answer is always the same: Use SVG if you<\/em> can!<\/em> I have nothing against SVG. It\u2019s just another approach for creating shapes using another syntax with another set of considerations. If SVG was my expertise, then I would be writing about that instead!<\/p>\n CSS is my field of expertise, so that\u2019s the approach we\u2019re covering for drawing shapes with code. Choosing CSS or SVG is typically a matter of choice. There may very well be a good reason why SVG is a better fit for your specific needs.<\/p>\n Many times, CSS will be your best bet for decorative things or when you\u2019re working with a specific element in the markup that contains real content to be styled. Ultimately, though, you will need to consider what your project\u2019s requirements are and decide whether a CSS shape is really what you are looking for.<\/p>\nTable of Contents<\/h3>\n
\n
Why Not SVG?<\/h2>\n
Your First Resource<\/h2>\n