Square
Basic#square {
width: 140px;
height: 140px;
background: #2563eb;
}
Here you’ll find a collection of geometric shapes created entirely with pure CSS, without images or SVG. Each one shows a different technique: border-radius for curves, the border trick for triangles, clip-path for polygons and stars, and pseudo-elements, transforms and gradients for the more complex shapes.
Every shape works in all current browsers. Pick a colour to recolour the whole collection, filter by type, then copy the CSS and HTML for the shape you need.
#square {
width: 140px;
height: 140px;
background: #2563eb;
}
#rectangle {
width: 160px;
height: 90px;
background: #2563eb;
}
#circle {
width: 140px;
height: 140px;
background: #2563eb;
border-radius: 50%;
}
#oval {
width: 200px;
height: 100px;
background: #2563eb;
border-radius: 50%;
}
#egg {
width: 126px;
height: 180px;
background: #2563eb;
border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%;
}
#semicircle {
width: 160px;
height: 80px;
background: #2563eb;
border-radius: 80px 80px 0 0;
}
#quarter-circle {
width: 120px;
height: 120px;
background: #2563eb;
border-top-left-radius: 100%;
}
#ring {
width: 140px;
height: 140px;
border: 22px solid #2563eb;
border-radius: 50%;
box-sizing: border-box;
}
#up-triangle {
width: 0;
height: 0;
border-bottom: 120px solid #2563eb;
border-left: 60px solid transparent;
border-right: 60px solid transparent;
}
#down-triangle {
width: 0;
height: 0;
border-top: 120px solid #2563eb;
border-left: 60px solid transparent;
border-right: 60px solid transparent;
}
#left-triangle {
width: 0;
height: 0;
border-right: 100px solid #2563eb;
border-top: 50px solid transparent;
border-bottom: 50px solid transparent;
}
#right-triangle {
width: 0;
height: 0;
border-left: 100px solid #2563eb;
border-top: 50px solid transparent;
border-bottom: 50px solid transparent;
}
#triangle-topleft {
width: 0;
height: 0;
border-top: 120px solid #2563eb;
border-right: 120px solid transparent;
}
#triangle-topright {
width: 0;
height: 0;
border-top: 120px solid #2563eb;
border-left: 120px solid transparent;
}
#triangle-bottomleft {
width: 0;
height: 0;
border-bottom: 120px solid #2563eb;
border-right: 120px solid transparent;
}
#triangle-bottomright {
width: 0;
height: 0;
border-bottom: 120px solid #2563eb;
border-left: 120px solid transparent;
}
/* height = width × 0.866 */
#eq-triangle {
width: 0;
height: 0;
border-bottom: 104px solid #2563eb;
border-left: 60px solid transparent;
border-right: 60px solid transparent;
}
#trapezium {
width: 80px;
height: 0;
border-bottom: 80px solid #2563eb;
border-left: 40px solid transparent;
border-right: 40px solid transparent;
}
#parallelogram {
width: 130px;
height: 75px;
background: #2563eb;
transform: skew(20deg);
}
#diamond {
width: 100px;
height: 100px;
background: #2563eb;
transform: rotate(45deg);
}
#pentagon {
width: 140px;
height: 133px;
background: #2563eb;
clip-path: polygon(50% 0, 100% 38%, 81% 100%, 19% 100%, 0 38%);
}
/* height = width × 0.866 */
#hexagon {
width: 160px;
height: 139px;
background: #2563eb;
clip-path: polygon(25% 0, 75% 0, 100% 50%, 75% 100%, 25% 100%, 0 50%);
}
#octagon {
width: 140px;
height: 140px;
background: #2563eb;
clip-path: polygon(29.3% 0, 70.7% 0, 100% 29.3%, 100% 70.7%,
70.7% 100%, 29.3% 100%, 0 70.7%, 0 29.3%);
}
#chevron {
width: 140px;
height: 90px;
background: #2563eb;
clip-path: polygon(0 0, 70% 0, 100% 50%, 70% 100%, 0 100%, 30% 50%);
}
#arrow {
width: 160px;
height: 100px;
background: #2563eb;
clip-path: polygon(0 30%, 60% 30%, 60% 0, 100% 50%, 60% 100%, 60% 70%, 0 70%);
}
#cross {
width: 120px;
height: 120px;
background:
linear-gradient(#2563eb 0 0) center / 36px 100% no-repeat,
linear-gradient(#2563eb 0 0) center / 100% 36px no-repeat;
}
#five-point-star {
width: 150px;
height: 143px;
background: #2563eb;
clip-path: polygon(50% 0, 61% 35%, 98% 35%, 68% 57%, 79% 91%,
50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%);
}
#six-point-star {
position: relative;
width: 0;
height: 0;
margin-bottom: 30px;
border-left: 50px solid transparent;
border-right: 50px solid transparent;
border-bottom: 80px solid #2563eb;
}
#six-point-star::after {
content: "";
position: absolute;
top: 30px;
left: -50px;
width: 0;
height: 0;
border-left: 50px solid transparent;
border-right: 50px solid transparent;
border-top: 80px solid #2563eb;
}
#twelve-point-star {
position: relative;
width: 100px;
height: 100px;
background: #2563eb;
}
#twelve-point-star::before,
#twelve-point-star::after {
content: "";
position: absolute;
inset: 0;
background: #2563eb;
transform: rotate(30deg);
}
#twelve-point-star::after {
transform: rotate(-30deg);
}
#heart {
position: relative;
width: 140px;
height: 115px;
}
#heart::before,
#heart::after {
content: "";
position: absolute;
top: 0;
left: 70px;
width: 70px;
height: 115px;
background: #2563eb;
border-radius: 50px 50px 0 0;
transform: rotate(-45deg);
transform-origin: 0 100%;
}
#heart::after {
left: 0;
transform: rotate(45deg);
transform-origin: 100% 100%;
}
#speech-bubble {
position: relative;
width: 140px;
height: 90px;
background: #2563eb;
border-radius: 12px;
}
#speech-bubble::before {
content: "";
position: absolute;
top: 18px;
left: -24px;
width: 0;
height: 0;
border-top: 13px solid transparent;
border-right: 26px solid #2563eb;
border-bottom: 13px solid transparent;
}
#crescent {
width: 120px;
height: 120px;
border-radius: 50%;
box-shadow: 28px 14px 0 0 #2563eb;
}
#pacman {
width: 0;
height: 0;
border: 60px solid #2563eb;
border-right-color: transparent;
border-radius: 50%;
}
#yin-yang {
width: 140px;
height: 140px;
border: 1px solid #2563eb;
border-radius: 50%;
background:
radial-gradient(25% 25% at 50% 25%, #2563eb 24%, #fff 26% 99%, #0000 101%),
radial-gradient(25% 25% at 50% 75%, #fff 24%, #2563eb 26% 99%, #0000 101%),
conic-gradient(#2563eb 50%, #fff 0);
}
#quartered-circle {
width: 0;
height: 0;
border: 60px solid #2563eb;
border-left-color: #facc15;
border-right-color: #facc15;
border-radius: 50%;
}
No shapes match your search.
Most of these shapes use one of four techniques. Once you know them, you can build almost any shape yourself:
/ syntax) give shapes like the egg.::before and ::after, then rotate or skew them into place, as in the heart and the twelve point star.Every shape on this page is drawn from the exact CSS shown in its code block, so what you see is what you copy. The shapes use IDs to keep the examples short; in a real project you may prefer a class so you can reuse the shape more than once on a page.
The classic way is the border trick: give an element a width and height of 0, set one border to a solid colour and the two borders next to it to transparent. Where the borders meet they form diagonal edges, so only a triangle is visible. A modern alternative is clip-path: polygon(50% 0, 100% 100%, 0 100%) on an element with a normal width, height and background.
clip-path is usually easier to read and adjust: the element keeps its real width and height, it can have a background image or gradient, and any polygon is possible. The border trick works in every browser ever made and is still handy for small arrows and tooltip tails. clip-path is supported in all current browsers.
Yes, for shapes built with a background, border-radius or clip-path, such as circles, polygons and speech bubbles. Shapes made with the border trick have a width and height of 0, so there is no room for content. Note that clip-path also clips the text, so keep text away from the edges.
Not directly: clip-path cuts off borders and box-shadow along with everything else. Instead, wrap the shape in a parent and use filter: drop-shadow() on the parent, which follows the clipped outline. For an outline, stack two clipped elements, the outer one slightly larger.