DEV Community

Christopher Chhim
Christopher Chhim

Posted on

How to make shapes with CSS

This blog is to help emerging front-end developers learn how to make CSS shapes- including myself! I believe that this is a skill worth learning if we wish to design websites to our liking. I have taken my inspiration from Afif's article The Modern Guide For Making CSS Shapes to help others learn how to make shapes of their choosing using Cascading Style Sheets (CSS).

The author of the article introduces readers to the possibility of using the elements of CSS to produce a shape instead of designing a shape the old-fashioned way. For example, Afif's guide suggests we can provide 4 points and cut the element instead of making 6 points for designing a hexagon. This means we can use CSS to think outside of a shape's boundaries to simplify the shape-designing process. Two key take away tips I've learned from this article are:

  • The polygon() function accepts points outside the [0% 100%] range. Using this function lets us clip shapes with fewer points
    but also opens up possibilities for creating additional shapes.

  • Switching axes is a reliable approach for creating shape variations.

I am not able to fully describe how CSS can be used to design every shape and for that reason, I will link to Afif's guide in this blog for anyone that needs it for future reference! I wish the best of luck to anyone stumbling upon this blog.

This post was heavily inspired from:
Afif, T. (2024, May 10) The Modern Guide For Making CSS Shapes
Retrieved from: [https://www.smashingmagazine.com/2024/05/modern-guide-making-css-shapes/]

Sentry blog image

How to reduce TTFB

In the past few years in the web dev world, we’ve seen a significant push towards rendering our websites on the server. Doing so is better for SEO and performs better on low-powered devices, but one thing we had to sacrifice is TTFB.

In this article, we’ll see how we can identify what makes our TTFB high so we can fix it.

Read more

Top comments (0)

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay